Hi,<div>If hope this is the right list to post a question like this. If not, my apologies -- please redirect me.</div><div><br></div><div>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).</div>
<div><br></div><div>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?</div>
<div><br></div><div>Thank you for any help. And thank you for this great tool.</div><div><br></div><div>Brent</div><div><br></div><div><pre style="text-align: left; background-color: rgb(238, 238, 238); "> 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();</pre></div>