-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm][Support] Enable pass timing in StandardInstrumentations constr… #108983
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
Conversation
…uctor Add two optional arguments to the llvm::StandardInstrumentations constructor that enables pass timings and pass timings per run. If the optional arguments are not provided, the TimePassesIsEnabled and TimePassesPerRun global variables will be read when constructing the TimePassesHandler object which will preserve the current behavior.
✅ With the latest revision this PR passed the C/C++ code formatter. |
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.
This looks okay to me but please wait for approval from somebody who contributes to this area.
One alternative would be to make another constructor with these two arguments (as bools not optionals) and delegate to that from this one. I don't personally feel strongly enough to ask you to change it, but it might fit better with the style used in these classes.
StandardInstrumentation::StandardInstrumentations(LLVMContext &Context, bool DebugLogging, bool VerifyEach, PrintPassOptions PrintPassOpts) :
StandardInstrumentations(Context, DebugLogging, VerifyEach, PrintPassOpts, TimePassesIsEnabled, TimePassesPerRun) {}
StandardInstrumentation::StandardInstrumentations(LLVMContext &Context, bool DebugLogging, bool VerifyEach, PrintPassOptions PrintPassOpts, bool EnableTimePasses, bool EnablePerRunTiming) :
TimePasses(EnableTimePasses, EnablePerRunTiming),
OptNone(DeubLogging),
[...]
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.
in general this direction makes sense
I'm not really a fan of the std::optional<bool>
though. what about just making the param a bool that defaults to false
, and the cl::opt
flags override it if they are explicitly specified?
also, we really should make the StandardInstrumentations
constructor take a StandardInstrumentationsOptions
as opposed to a bunch of separate params, but that can be a followup
Thanks for taking a look, Arthur.
If I understand you correctly, you are suggesting
I think explicitly specifying the option will set
That is a good idea. I am happy to take a stab at it later. |
I meant And ideally we'd change clang to also use this rather than setting |
…rity to cl::opts that have been set.
Ah, thanks. I didn't know about |
Ugh! So this gets a little messier. The actual command line option is To do as you suggest, that
I think part of the trouble there is that the legacy pass manager still uses this global. In clang, |
I see... But then if we already need to set |
The idea was to allow enabling timers using either the However, this would only make things "cleaner" for the new pass manager. We could try to expose just this tiny bit of functionality in the legacy pass manager too, but I haven't looked too closely at that code to see if it would be feasible. |
I think it would be acceptable, for My intention was to try and set things up so we could slowly migrate to using constructor arguments to enable timings in the pass manager instead of relying solely on globals. |
Closing this since @aeubanks concerns are valid. One ends up having to do two different things since the legacy pass manager used by the backend still requires global variables to be set in order to enable timings. A different approach may be warranted. |
…uctor
Add two optional arguments to the llvm::StandardInstrumentations constructor that enables pass timings and pass timings per run. If the optional arguments are not provided, the TimePassesIsEnabled and TimePassesPerRun global variables will be read when constructing the TimePassesHandler object which will preserve the current behavior.
Notes for reviewers: This was motivated by #107270 which could be simplified if timing of passes could be enabled without having to set
llvm::TimePassesIsEnabled
andllvm::TimePassesPerRun
directly.