Hi, If hope this is the right list to post a question like this. If not, my apologies -- please redirect me. Following the Kaledoscope example I am trying to write a simple JIT and compile my own small language using LLVM. Compilation happens using the C++ api by constructing a VM and emitting code using the api (just as the Kaledoscope example). 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 (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? 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(); -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111104/edc16816/attachment.html>
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 goodcode 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
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>
Maybe Matching Threads
- [LLVMdev] Question on JIT optimizations
- [LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)
- [LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)
- [LLVMdev] ARM opcode format
- [LLVMdev] Kaleidoscope toy4 failure seg fault on llvm::ExecutionEngine::getTargetData (this=0x0)