Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2650,6 +2650,25 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
comp_ctx->comp_data = comp_data;

/* Create LLVM context, module and builder */
#if LLVM_VERSION_MAJOR >= 21
/* Construct an LLVMContext directly, note:
different from non LAZY JIT mode, no need to dispose this context, if
will be disposed when the thread safe context is disposed */
comp_ctx->context = LLVMContextCreate();
if (!comp_ctx->context) {
aot_set_last_error("create LLVM Context failed.");
goto fail;
}

/* Wrap the LLVM context in a thread safe context. */
comp_ctx->orc_thread_safe_context =
LLVMOrcCreateNewThreadSafeContextFromLLVMContext(comp_ctx->context);
if (!comp_ctx->orc_thread_safe_context) {
aot_set_last_error(
"Create LLVM ThreadSafeContext from LLVMContext failed.");
goto fail;
}
#else /* LLVM_VERSION_MAJOR < 21 */
comp_ctx->orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext();
if (!comp_ctx->orc_thread_safe_context) {
aot_set_last_error("create LLVM ThreadSafeContext failed.");
Expand All @@ -2664,6 +2683,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
aot_set_last_error("get context from LLVM ThreadSafeContext failed.");
goto fail;
}
#endif /* LLVM_VERSION_MAJOR >= 21 */

if (!(comp_ctx->builder = LLVMCreateBuilderInContext(comp_ctx->context))) {
aot_set_last_error("create LLVM builder failed.");
Expand Down
9 changes: 7 additions & 2 deletions core/iwasm/compilation/aot_llvm_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,23 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
cl::ParseCommandLineOptions(2, argv);
#if LLVM_VERSION_MAJOR < 17
PGO = PGOOptions("", "", "", PGOOptions::IRInstr);
#else
#elif LLVM_VERSION_MAJOR < 22
auto FS = vfs::getRealFileSystem();
PGO = PGOOptions("", "", "", "", FS, PGOOptions::IRInstr);
#else
PGO = PGOOptions("", "", "", "", PGOOptions::IRInstr);
#endif
}
else if (comp_ctx->use_prof_file) {
#if LLVM_VERSION_MAJOR < 17
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", PGOOptions::IRUse);
#else
#elif LLVM_VERSION_MAJOR < 22
auto FS = vfs::getRealFileSystem();
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", "", FS,
PGOOptions::IRUse);
#else
PGO =
PGOOptions(comp_ctx->use_prof_file, "", "", "", PGOOptions::IRUse);
#endif
}

Expand Down
Loading