Juneyoung Lee via llvm-dev
2020-Dec-04 04:28 UTC
[llvm-dev] registering passes at the beginning/end of opt passes (new pass manager)
Hello all, Can I register passes at the beginning/end of opt passes (new pass manager)? I found that registerPipelineStartEPCallback/registerOptimizerLastEPCallback work successfully for clang, but they don't fire when opt -passes="" is used. Thanks, Juneyoung -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201204/c89e4e48/attachment.html>
Min-Yih Hsu via llvm-dev
2020-Dec-04 05:57 UTC
[llvm-dev] registering passes at the beginning/end of opt passes (new pass manager)
I’m not sure what’s your context. I think `-passes` is only used for specify the entire pipeline instead of inserting callbacks into an existing pipeline. You can either directly modify PassBuilder’s code to run Passes before/after a Pass. Or writing a new PassManager PassPlugin and use the PassBuilder instance in there (see the comments in include/llvm/Passes/PassPlugin.h [1]) to call registerPipelineStartEPCallback. Then load that plugin using opt. [1] https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Passes/PassPlugin.h#L96 <https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/Passes/PassPlugin.h#L96> Best -Min> On Dec 3, 2020, at 8:28 PM, Juneyoung Lee via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello all, > > Can I register passes at the beginning/end of opt passes (new pass manager)? > > I found that registerPipelineStartEPCallback/registerOptimizerLastEPCallback work successfully for clang, but they don't fire when opt -passes="" is used. > > Thanks, > Juneyoung > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201203/1e865f35/attachment.html>
Arthur Eubanks via llvm-dev
2020-Dec-04 07:25 UTC
[llvm-dev] registering passes at the beginning/end of opt passes (new pass manager)
There are various opt options [1] that let you specify passes to add at specific points in the pipeline. Also, specifying a target may cause the corresponding TargetMachine to register pass callbacks. Something like "-passes=default<O2>" that creates a full pipeline will add those passes to the pipeline. Otherwise they aren't invoked. [1]: https://github.com/llvm/llvm-project/blob/f5f1a5c2448e31f3c7e6f85b378372a02f8d3e43/llvm/tools/opt/NewPMDriver.cpp#L73 On Thu, Dec 3, 2020 at 8:29 PM Juneyoung Lee via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello all, > > Can I register passes at the beginning/end of opt passes (new pass > manager)? > > I found that > registerPipelineStartEPCallback/registerOptimizerLastEPCallback work > successfully for clang, but they don't fire when opt -passes="" is used. > > Thanks, > Juneyoung > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201203/c125f193/attachment.html>
Juneyoung Lee via llvm-dev
2020-Dec-07 10:46 UTC
[llvm-dev] registering passes at the beginning/end of opt passes (new pass manager)
Okay, I tried something like this: Given opt -passes='...', my bash script strips the quotes, puts module(mypass) at the begin/end, put quotes again, and runs it. mypass is a module-level pass. ex) Given opt -passes='sroa' , it emits opt -passes='module(mypass),sroa,module(mypass)' The emitted command seems working in this case, but I found that it breaks when loop-level passes are there: ex) Running opt -passes='module(mypass),loop(unswitch<nontrivial>),module(mypass)' shows: build/bin/opt: invalid use of 'loop' pass as module pipeline Is there a way to correctly add 'mypass' to the begin/end of the passes regardless of the level of the pipeline? Thanks, Juneyoung On Fri, Dec 4, 2020 at 1:28 PM Juneyoung Lee <juneyoung.lee at sf.snu.ac.kr> wrote:> Hello all, > > Can I register passes at the beginning/end of opt passes (new pass > manager)? > > I found that > registerPipelineStartEPCallback/registerOptimizerLastEPCallback work > successfully for clang, but they don't fire when opt -passes="" is used. > > Thanks, > Juneyoung > >-- Juneyoung Lee Software Foundation Lab, Seoul National University -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201207/8937dceb/attachment.html>