-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add IR-based PGO #2474
Add IR-based PGO #2474
Conversation
driver/cl_options_instrumentation.h
Outdated
PGO_IRBasedUse, | ||
}; | ||
extern PGOKind pgoMode; | ||
inline bool isDoingPGOInstr() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this, but these names reads a bit odd – maybe isPGOInstrumenting
, instrumentingForPGO
, or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and then the other isUsingPGOProfile
?
You have probably thought about this, but maybe an alternative naming scheme would be "AST" instead of "frontend"? |
I used "frontend" because I think that's what is usually used in LLVM circles. In LLVM code, it's called "ClangPGO" (frontend based) and "LLVMPGO" (IR based). |
I'm renaming it to "AST Based", I like that better indeed. |
@jondegenhardt Done! :-) Important difference between AST- (old) and IR-based PGO in practical use is that the other commandline flags must be the same with IR PGO. This means that you have to specify |
Very nice! I won't have a chance to try it until after new year, but I'll give it shot then. |
Strange, anybody know why the file is not created? The CI systems error with:
But the lit-test works fine on my machine. Edit: nevermind, I found the problem. |
2dc9902
to
1474769
Compare
The failure on Windows is due to some bug in LLVM. I've a testcase and will submit it to their bugtracker. |
Shall I fully disable it on Windows, or only mark the test as XFail ? (only generating the profile for a Windows target is broken; profile usage still works) |
(needless to say, I'd like to get this in quick, so other folks can start testing) |
Thanks for doing this. Will it eventually supersede the AST-based one? [I would be looking forward to the resulting code cleanup.] Wrt. Windows, XFAIL sounds good to me, as does a proper error message for the time being. |
Maybe. The AST-based code makes a few PGO items easier and facilitates prototyping things (like the virtual call promotion I worked on). But probably most importantly, the AST-based instrumentation is the same as what's needed for code coverage. (https://clang.llvm.org/docs/SourceBasedCodeCoverage.html)
"cleanup" :'( I'll add the error for Windows targets. I've already sent a question about the error to LLVM folks, I think it's just a bug somewhere (I can get it to (appear to) work with llvm's cmdline tools). |
What I actually meant was code reduction, the less code to maintain, the better ;) - even more so if scattered around the code base like this one. |
@@ -1033,6 +1032,8 @@ int cppmain(int argc, char **argv) { | |||
global.lib_ext = "a"; | |||
} | |||
|
|||
opts::initializeInstrumentationOptionsFromCmdline(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i had to place the call here, after the triple has been initialized. The option sanity-checking needs to know the target triple, and I didn't want to separate the sanity checking from the initialization code.
Any concerns before I pull this? |
First, some refactoring such that the code doesn't assume just one kind of PGO.