Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IR PGO not working on Windows #2539

Closed
JohanEngelen opened this issue Jan 26, 2018 · 6 comments
Closed

IR PGO not working on Windows #2539

JohanEngelen opened this issue Jan 26, 2018 · 6 comments

Comments

@JohanEngelen
Copy link
Member

IR PGO is disabled on Windows right now, see #2474

@Hardcode84 found a testcase, demonstrating (most likely) a bug in LLVM:

// File: main.d
int foo()
{
  return 42;
}

ldc2 main -output-ll output:

; ModuleID = 'main.d'
source_filename = "main.d"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

%0 = type { i32, i32, [5 x i8] }
%object.ModuleInfo = type { i32, i32 }

$_D4main3fooFZi = comdat any

$_D4main12__ModuleInfoZ = comdat any

@_D4main12__ModuleInfoZ = global %0 { i32 -2147483644, i32 0, [5 x i8] c"main\00" }, comdat ; [#uses = 1]
@_D4main11__moduleRefZ = linkonce_odr global %object.ModuleInfo* bitcast (%0* @_D4main12__ModuleInfoZ to %object.ModuleInfo*), section ".minfo" ; [#uses = 1]
@llvm.used = appending global [1 x i8*] [i8* bitcast (%object.ModuleInfo** @_D4main11__moduleRefZ to i8*)], section "llvm.metadata" ; [#uses = 0]

; [#uses = 0]
; Function Attrs: uwtable
define i32 @_D4main3fooFZi() #0 comdat {
  ret i32 42
}

attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "target-cpu"="x86-64" "target-features"="+cx16" "unsafe-fp-math"="false" }

!llvm.linker.options = !{}
!llvm.ident = !{!0}

!0 = !{!"ldc version 1.7.0git-43c02ce-dirty"}

opt -pgo-instr-gen -instrprof -verify main.ll -S output:

comdat global value has private linkage
[1 x i64]* @__profc__D4main3fooFZi
LLVM ERROR: Broken module found, compilation aborted!

Error goes away if comdat is removed from foo.

@JohanEngelen
Copy link
Member Author

reported here: https://bugs.llvm.org/show_bug.cgi?id=36120

@kinke
Copy link
Member

kinke commented Feb 27, 2018

For AST-based PGO, we override the linkage specifically here.

@kinke
Copy link
Member

kinke commented Jul 30, 2018

It might be easily worked around in our LLVM fork, by modding these 3 lines. I'll check it out.

@kinke
Copy link
Member

kinke commented Jul 31, 2018

Apparently so, PASS: LDC :: PGO/irbased_indirect_calls.d. Not sure if I'll do a third LLVM 6.0.1 release or delay it until LLVM 7.

@jondegenhardt
Copy link
Contributor

An issue reference, in the off-chance this would help the IR-PGO+LTO case: #2582

@kinke
Copy link
Member

kinke commented Aug 19, 2018

Resolved by #2795.

@kinke kinke closed this as completed Aug 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants