Execution Engine: CodeGenOpt level

Hi,

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)?

Thank you.

Best regards,
Nurudeen.

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)?

  From the source code I'm reading, you might have to creat another JIT with
different opt level.

Regards,
chenwj

Hi Chenwj,

Thank you for your response.

The problem with this approach is that global mappings have to be
recreated in the new JIT. Can this be somehow avoided?

Best regards,
Nurudeen.

The problem with this approach is that global mappings have to be
recreated in the new JIT. Can this be somehow avoided?

  I am afraid not. Besides, when you create another ExecutionEngine, it'll
take ownership of the module which contains the function you want to compile.
Maybe you have creat another module, perhaps. But I am not a LLVM expert, I
leave for other's comment.

Regards,
chenwj

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On Behalf Of nlamee@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.

Neat approach, I think. So you set PassManagers's Opt level rather
then ExecutionEngine's one?

Regards,
chenwj

From: 陳韋任 [mailto:chenwj@iis.sinica.edu.tw]
Subject: Re: [LLVMdev] Execution Engine: CodeGenOpt level

So you set PassManagers's Opt level rather then ExecutionEngine's one?

That's correct. I have no idea what difference doing one or the other (or both) makes.

- 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.

Thank you.
Nurudeen.