Support AOT compiler with LLVM 17 (#2567)

Adapt API usage to new interfaces where applicable, including LLVM function
usage, obsoleted llvm::Optional type and removal of unavailable headers.

Know issues:
- AOT static PGO isn't enabled
- LLVM JIT may run failed due to llvm_orc_registerEHFrameSectionWrapper
  isn't linked into iwasm
This commit is contained in:
Alfred E. Neumayer
2023-09-25 13:00:46 +02:00
committed by GitHub
parent f474f3d668
commit 99b47fd334
5 changed files with 57 additions and 3 deletions

View File

@ -526,12 +526,18 @@ aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module,
}
wasm_runtime_free(params);
params = NULL;
#if LLVM_VERSION_MAJOR < 17
if (aot_target_precheck_can_use_musttail(comp_ctx)) {
LLVMSetTailCallKind(retval, LLVMTailCallKindMustTail);
}
else {
LLVMSetTailCallKind(retval, LLVMTailCallKindTail);
}
#else
LLVMSetTailCall(retval, true);
#endif
if (ret_type == VOID_TYPE) {
if (!LLVMBuildRetVoid(b)) {
goto fail;
@ -2172,8 +2178,10 @@ bool
aot_compiler_init(void)
{
/* Initialize LLVM environment */
#if LLVM_VERSION_MAJOR < 17
LLVMInitializeCore(LLVMGetGlobalPassRegistry());
#endif
#if WASM_ENABLE_WAMR_COMPILER != 0
/* Init environment of all targets for AOT compiler */
LLVMInitializeAllTargetInfos();