[LLVMdev] Question on JIT optimizations

Brent Walker brenthwalker at gmail.com
Sat Nov 5 08:01:11 PDT 2011


Exactly what I was looking for.  Thanks a lot.

Brent

On Sat, Nov 5, 2011 at 2:35 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Brent,
>
> > The code in this setup will be optimized according to the optimizer
> pipeline one
> > sets up as in the code below.  I find that if I only use the passes
> below the
> > quality of the code is not that good
>
> code quality will be dreadful if you don't promote memory accesses to
> registers
> right at the start, using eg mem2reg or scalarrepl.
>
>  (for example inlining is not aggressive
> > enough) -- moreover the number of passes is overwhelming and the order
> in which
> > they are specified seems important and I do not have the expertise to
> set that
> > up.  What I would like, is to set up the passes in exactly the same as
> clang -O2
> > or llvm-gcc -O2 do.  Is there some way to get that behavior using the
> api below?
>
> You can use a PassManagerBuilder for this.  For some reason it is tucked
> away in
> an obscure corner of include:
> include/llvm/Transforms/IPO/PassManagerBuilder.h
>
> Ciao, Duncan.
>
> >   How do language implementors do this in the LLVM environment?
> >
> > Thank you for any help.  And thank you for this great tool.
> >
> > Brent
> >
> >    FunctionPassManager OurFPM(TheModule);
> >
> >    // Set up the optimizer pipeline.  Start with registering info about
> how the
> >    // target lays out data structures.
> >    OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));
> >    // Provide basic AliasAnalysis support for GVN.
> >    OurFPM.add(createBasicAliasAnalysisPass());
> >    // Do simple"peephole"  optimizations and bit-twiddling optzns.
> >    OurFPM.add(createInstructionCombiningPass());
> >    // Reassociate expressions.
> >    OurFPM.add(createReassociatePass());
> >    // Eliminate Common SubExpressions.
> >    OurFPM.add(createGVNPass());
> >    // Simplify the control flow graph (deleting unreachable blocks, etc).
> >    OurFPM.add(createCFGSimplificationPass());
> >
> >    OurFPM.doInitialization();
> >
> >    // Set the global so the code gen can use this.
> >    TheFPM =&OurFPM;
> >
> >    // Run the main"interpreter loop"  now.
> >    MainLoop();
> >
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111106/a48b5cb7/attachment.html>


More information about the llvm-dev mailing list