Selecting optimization passes in the JIT

When trying to narrow down which pass causes a failure with the static compiler, I will often produce an IR file that I will pass to the “opt” tool and enable/disable passes until I spot which pass causes the issue.

I am wondering how I might do that with the JIT. I don’t know much about the JIT or the application that is using it, but as far as I can tell, the application sets up the JIT with an optimization level (i.e. -O2) and uses it. What I’d like to do instead is manually specify which passes are to be run (much like I do with opt).

Thanks for your help,

Nemanja

Hi Nemanja,

LLVM’s JIT libraries (ORC and MCJIT) do not run IR level optimizations in their default configurations. Running IR passes is left for the client to do before they add the IR to the JIT. The optimization level passed to LLI (and passed from there to EngineBuilder::setOptLevel) only controls the CodeGen optimizations.

So assuming you’re running LLI (or something like it) you’re free to run any IR passes you like using opt before you invoke LLI to run the IR.

If you’re interested in manually specifying which CodeGen passes to run this is also possible, but more involved. Let me know if you would like help with this.

Cheers,
Lang.