[LLVMdev] Question on JIT optimizations
brenthwalker at gmail.com
Sat Nov 5 08:01:11 PDT 2011
Exactly what I was looking for. Thanks a lot.
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
> 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:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev