Russell Wallace via llvm-dev
2015-Sep-20 06:28 UTC
[llvm-dev] How to invoke simplifycfg from code
Simplifycfg doesn't get run by default even with -O3, but 'opt -simplifycfg' can do it. I'm looking to add this functionality to an optimizer program that uses the llvm libraries. What's the best way to do this? I don't really mind whether it becomes available as a command line option as in opt, or I need to hardcode it as always on. To make it available as a command line option... I'm looking at the code for opt, but it makes no reference to simplifycfg anywhere in the code. I'm guessing it does something else that gets that option linked in and somehow thereby connects that to activating the actual pass; how is this done? Alternatively in an attempt to hardwire it I got as far as FPM.add(new SimplifyCFGPass); but that fails to compile because SimplifyCFGPass isn't of a compatible type, which indeed it isn't; what should I be doing here? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150920/ed626eca/attachment.html>
Aditya Nandakumar via llvm-dev
2015-Sep-20 10:36 UTC
[llvm-dev] How to invoke simplifycfg from code
If you look at adding simplify cfg to your pass pipeline - look at toy.cpp - I believe it adds simplifyCFG pass as TheFPM->add(createCFGSimplificationPass()); Aditya On Sat, Sep 19, 2015 at 11:29 PM Russell Wallace via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Simplifycfg doesn't get run by default even with -O3, but 'opt > -simplifycfg' can do it. I'm looking to add this functionality to an > optimizer program that uses the llvm libraries. What's the best way to do > this? I don't really mind whether it becomes available as a command line > option as in opt, or I need to hardcode it as always on. > > To make it available as a command line option... I'm looking at the code > for opt, but it makes no reference to simplifycfg anywhere in the code. I'm > guessing it does something else that gets that option linked in and somehow > thereby connects that to activating the actual pass; how is this done? > > Alternatively in an attempt to hardwire it I got as far as FPM.add(new > SimplifyCFGPass); but that fails to compile because SimplifyCFGPass isn't > of a compatible type, which indeed it isn't; what should I be doing here? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://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/20150920/367c34c6/attachment.html>
Hal Finkel via llvm-dev
2015-Sep-20 12:36 UTC
[llvm-dev] How to invoke simplifycfg from code
Hi Russell, Can you run your IR though opt with -O3 and -print-after-all and see when the block becomes empty? PassManagerBuilder::populateModulePassManager has, fairly near the end: MPM.add(createCFGSimplificationPass()); but, other things do run afterward. Maybe we need another one of these closer to the end? One other thing to realize is that an empty block like this might not actually turn up in any generated machine code because of how MachineBlockPlacement (and other MI-level passes) work. -Hal ----- Original Message -----> From: "Russell Wallace via llvm-dev" <llvm-dev at lists.llvm.org> > To: "llvm-dev" <llvm-dev at lists.llvm.org> > Sent: Sunday, September 20, 2015 1:28:56 AM > Subject: [llvm-dev] How to invoke simplifycfg from code > > Simplifycfg doesn't get run by default even with -O3, but 'opt > -simplifycfg' can do it. I'm looking to add this functionality to an > optimizer program that uses the llvm libraries. What's the best way > to do this? I don't really mind whether it becomes available as a > command line option as in opt, or I need to hardcode it as always > on. > > > To make it available as a command line option... I'm looking at the > code for opt, but it makes no reference to simplifycfg anywhere in > the code. I'm guessing it does something else that gets that option > linked in and somehow thereby connects that to activating the actual > pass; how is this done? > > > Alternatively in an attempt to hardwire it I got as far as > FPM.add(new SimplifyCFGPass); but that fails to compile because > SimplifyCFGPass isn't of a compatible type, which indeed it isn't; > what should I be doing here? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
Russell Wallace via llvm-dev
2015-Sep-20 13:15 UTC
[llvm-dev] How to invoke simplifycfg from code
Okay, as far as I can see looking through the output of that, the empty block isn't created near the end, it exists at the start and never goes away. On Sun, Sep 20, 2015 at 1:36 PM, Hal Finkel <hfinkel at anl.gov> wrote:> Hi Russell, > > Can you run your IR though opt with -O3 and -print-after-all and see when > the block becomes empty? PassManagerBuilder::populateModulePassManager has, > fairly near the end: > > MPM.add(createCFGSimplificationPass()); > > but, other things do run afterward. Maybe we need another one of these > closer to the end? > > One other thing to realize is that an empty block like this might not > actually turn up in any generated machine code because of how > MachineBlockPlacement (and other MI-level passes) work. > > -Hal > > ----- Original Message ----- > > From: "Russell Wallace via llvm-dev" <llvm-dev at lists.llvm.org> > > To: "llvm-dev" <llvm-dev at lists.llvm.org> > > Sent: Sunday, September 20, 2015 1:28:56 AM > > Subject: [llvm-dev] How to invoke simplifycfg from code > > > > Simplifycfg doesn't get run by default even with -O3, but 'opt > > -simplifycfg' can do it. I'm looking to add this functionality to an > > optimizer program that uses the llvm libraries. What's the best way > > to do this? I don't really mind whether it becomes available as a > > command line option as in opt, or I need to hardcode it as always > > on. > > > > > > To make it available as a command line option... I'm looking at the > > code for opt, but it makes no reference to simplifycfg anywhere in > > the code. I'm guessing it does something else that gets that option > > linked in and somehow thereby connects that to activating the actual > > pass; how is this done? > > > > > > Alternatively in an attempt to hardwire it I got as far as > > FPM.add(new SimplifyCFGPass); but that fails to compile because > > SimplifyCFGPass isn't of a compatible type, which indeed it isn't; > > what should I be doing here? > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > > -- > Hal Finkel > Assistant Computational Scientist > Leadership Computing Facility > Argonne National Laboratory >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150920/e5cd4627/attachment-0001.html>