[LLVMdev] Execution Engine: CodeGenOpt level
Caldarale, Charles R
Chuck.Caldarale at unisys.com
Thu Mar 22 20:17:45 PDT 2012
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of nlamee at cs.mcgill.ca
> Subject: [LLVMdev] Execution Engine: CodeGenOpt level
> How can I dynamically change the code generation optimization level (e.g.,
> None) of a JIT in other to recompile a function with a new optimization
> level (e.g., Default)?
We set the optimization level with a PassManagerBuilder, which is initialized for each function compilation:
PassManagerBuilder PMBuilder;
...
PMBuilder.OptLevel = conf.value_of(CF_OPTLEVEL);
PMBuilder.SizeLevel = conf.is_set(CF_OPTSIZE) ? 1 : 0;
PMBuilder.DisableUnitAtATime = !conf.is_set(CF_OPTUNIT);
PMBuilder.DisableUnrollLoops = !conf.is_set(CF_UNROLL);
PMBuilder.DisableSimplifyLibCalls = !conf.is_set(CF_SIMPLIB);
if (Opt != CodeGenOpt::None) {
PMBuilder.Inliner = createFunctionInliningPass(Opt == CodeGenOpt::Aggressive ? 250 : 200);
}
pFPasses = new FunctionPassManager(pMod);
pFPasses->add(new TargetData(*TD));
PMBuilder.populateFunctionPassManager(*pFPasses);
pFPasses->doInitialization();
pFPasses->run(*pFun);
pFPasses->doFinalization();
delete pFPasses;
pMPasses = new PassManager();
pMPasses->add(new TargetData(*TD));
pMPasses->add(createCFGSimplificationPass());
pMPasses->add(createBlockPlacementPass());
PMBuilder.populateModulePassManager(*pMPasses);
pMPasses->run(*pMod);
delete pMPasses;
(There is likely some redundancy and unnecessary steps in the above.)
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
More information about the llvm-dev
mailing list