[llvm-dev] Need help on JIT compilation speed

Terry Guo via llvm-dev
Tue, 16 Jun 2020 15:39:44 -0000

Hi there,

I am trying to JIT a rather big wasm bytecode program to x86 native code
and running into this JIT compilation time issue. In the first stage, I use
MCJIT to translate wasm bytecode to a single LLVM IR Module which ends up
with 927 functions. Then it took a pretty long time to apply several
optimization passes to this big IR module and finally generate x86 code.
What should I do to shorten the compilation time? Is it possible to compile
this single big IR Module with MCJIT in parallel? Is OrcV2 JIT faster than
MCJIT? Can the 'concurrent compilation' feature mentioned in Orcv2
webpage
help on this? Thanks in advance for any advice.

This is how I organized the optimization pass:

    LLVMAddBasicAliasAnalysisPass(comp_ctx->pass_mgr);
    LLVMAddPromoteMemoryToRegisterPass(comp_ctx->pass_mgr);
    LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
    LLVMAddJumpThreadingPass(comp_ctx->pass_mgr);
    LLVMAddConstantPropagationPass(comp_ctx->pass_mgr);
    LLVMAddReassociatePass(comp_ctx->pass_mgr);
    LLVMAddGVNPass(comp_ctx->pass_mgr);
    LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);

This is how I apply passes to my single IR module (which actually includes
927 functions)

if (comp_ctx->optimize) {
      LLVMInitializeFunctionPassManager(comp_ctx->pass_mgr);
      for (i = 0; i < comp_ctx->func_ctx_count; i++)
          LLVMRunFunctionPassManager(comp_ctx->pass_mgr,
                                     comp_ctx->func_ctxes[i]->func);
  }

BR,
Terry
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20200616/f95d4bb4/attachment.html>