Enable aot compiler with llvm-14/15 (#1252)

Enable aot compiler and jit based on llvm-14.0 and llvm-15.0git,
replace LLVMBuildLoad/LLVMBuildInBoundsGEP/LLVMBuildCall with
LLVMBuildLoad2/LLVMBuildInBoundsGEP2/LLVMBuildCall2, and pass
them with related types, so as to meet the requirements of opaque
pointers.

And fix several compilation errors for llvm-14.0/15.0git.

Most spec cases and standalone cases are tested.
This commit is contained in:
Wenyong Huang
2022-06-28 14:53:01 +08:00
committed by GitHub
parent 2746d29751
commit 5e238322c2
12 changed files with 431 additions and 301 deletions

View File

@ -2641,7 +2641,12 @@ apply_func_passes(AOTCompContext *comp_ctx)
LLVMAddLoopVectorizePass(pass_mgr);
LLVMAddSLPVectorizePass(pass_mgr);
LLVMAddLoopRotatePass(pass_mgr);
#if LLVM_VERSION_MAJOR < 15
LLVMAddLoopUnswitchPass(pass_mgr);
/* Binding disabled in LLVM 15, don't add the pass util we can either
add a binding to SimpleLoopUnswitchPass, or add it to
aot_llvm_extra.cpp */
#endif
LLVMAddInstructionCombiningPass(pass_mgr);
LLVMAddCFGSimplificationPass(pass_mgr);
if (!comp_ctx->enable_thread_mgr) {
@ -2694,8 +2699,10 @@ apply_lto_passes(AOTCompContext *comp_ctx)
LLVMPassManagerBuilderSetOptLevel(pass_mgr_builder, comp_ctx->opt_level);
LLVMPassManagerBuilderPopulateModulePassManager(pass_mgr_builder,
common_pass_mgr);
#if LLVM_VERSION_MAJOR < 15
LLVMPassManagerBuilderPopulateLTOPassManager(pass_mgr_builder,
common_pass_mgr, true, true);
#endif
#if WASM_ENABLE_LAZY_JIT == 0
LLVMRunPassManager(common_pass_mgr, comp_ctx->module);