-
-
Notifications
You must be signed in to change notification settings - Fork 261
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 + LTO: error: Not an IR level instrumentation profile #2582
Comments
Thanks, I can reproduce it too on macOS with LLVM 6 and trunk. With Clang, these steps do work. But clang reports that the only function (main) is outdated (hash mismatch), so effectively it's not working. Without So the workaround for now is to not use |
Thanks, I'll try this. Another piece is how it interacts with building phobos/druntime with LTO, e.g.
From your description it sounds like this should work. After all, what this step is doing is generating the IR, not the final optimization. I should be able to try it before too long. |
The workaround doesn't work when building with LTO against phobos/druntime. Somewhat obvious in retrospect. The druntime/phobos libs are built with |
Reproducing testcase for Lit: // Test combination of IR-based PGO and LTO
// REQUIRES: PGO_RT
// REQUIRES: LTO
// REQUIRES: atleast_llvm309
// There is an LLVM bug with IR-based LTO on Windows.
// XFAIL: Windows
// RUN: %ldc -flto=full -fprofile-generate=%t.profraw -run %s \
// RUN: && %profdata merge %t.profraw -o %t.profdata \
// RUN: && %ldc -flto=full -c -output-ll -of=%t.use.ll -fprofile-use=%t.profdata %s
// R UN: && FileCheck %s -check-prefix=PROFUSE < %t.use.ll
import ldc.attributes : weak;
extern (C)
{ // simplify name mangling for simpler string matching
@weak // disable reasoning about this function
void hot()
{
}
void luke()
{
}
void cold()
{
}
void function() foo;
@weak // disable reasoning about this function
void select_func(int i)
{
if (i < 1700)
foo = &hot;
else if (i < 1990)
foo = &luke;
else
foo = &cold;
}
} // extern C
// PROFUSE-LABEL: @_Dmain(
int main()
{
for (int i; i < 2000; ++i)
{
select_func(i);
// PROFUSE: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo
// PROFUSE: [[REG2:%[0-9]+]] = icmp eq void ()* [[REG1]], @hot
// PROFUSE: call void @hot()
// PROFUSE: call void [[REG1]]()
foo();
}
return 0;
} |
I've dug a little more. This is also broken with Clang, at least partly. (contrary to what I reported earlier). I'll discuss it with the LLVM team. |
FWIW, using |
Combining IR-PGO and LTO fails to build. This was tested on OSX. Tried a simple helloworld program as shown below. The same commands work when using AST-PGO (the
fprofile-instr-[generate|use]
versions of the instructions with theinstr-
bit).The behavior is as if using LTO switches profile generation back to AST. In fact, in the examples below, changing the LTO builds to use
fprofile-generate
/fprofile-instr-use
builds successfully, suggesting that this may be what is happening.The text was updated successfully, but these errors were encountered: