[llvm-dev] How to invoke simplifycfg from code

Russell Wallace via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 20 06:15:19 PDT 2015


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>


More information about the llvm-dev mailing list