Skip to content

Commit 450363d

Browse files
committed
Update LLVM to 21.1.2.
This required minor changes to LLVMContext construction and PGOOptions.
1 parent 3f4145e commit 450363d

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

build-scripts/build_llvm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,17 @@ def main():
294294
"arc": {
295295
"repo": "https://github.com/llvm/llvm-project.git",
296296
"repo_ssh": "[email protected]:llvm/llvm-project.git",
297-
"branch": "release/18.x",
297+
"branch": "release/21.x",
298298
},
299299
"xtensa": {
300300
"repo": "https://github.com/espressif/llvm-project.git",
301301
"repo_ssh": "[email protected]:espressif/llvm-project.git",
302-
"branch": "xtensa_release_18.1.2",
302+
"branch": "xtensa_release_21.1.2",
303303
},
304304
"default": {
305305
"repo": "https://github.com/llvm/llvm-project.git",
306306
"repo_ssh": "[email protected]:llvm/llvm-project.git",
307-
"branch": "release/18.x",
307+
"branch": "release/21.x",
308308
},
309309
}
310310

core/iwasm/compilation/aot_llvm.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,18 +2656,21 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
26562656
comp_ctx->comp_data = comp_data;
26572657

26582658
/* Create LLVM context, module and builder */
2659-
comp_ctx->orc_thread_safe_context = LLVMOrcCreateNewThreadSafeContext();
2660-
if (!comp_ctx->orc_thread_safe_context) {
2661-
aot_set_last_error("create LLVM ThreadSafeContext failed.");
2659+
/* Construct an LLVMContext directly, note:
2660+
different from non LAZY JIT mode, no need to dispose this context, if
2661+
will be disposed when the thread safe context is disposed */
2662+
comp_ctx->context = LLVMContextCreate();
2663+
if (!comp_ctx->context) {
2664+
aot_set_last_error("create LLVM Context failed.");
26622665
goto fail;
26632666
}
26642667

2665-
/* Get a reference to the underlying LLVMContext, note:
2666-
different from non LAZY JIT mode, no need to dispose this context,
2667-
if will be disposed when the thread safe context is disposed */
2668-
if (!(comp_ctx->context = LLVMOrcThreadSafeContextGetContext(
2669-
comp_ctx->orc_thread_safe_context))) {
2670-
aot_set_last_error("get context from LLVM ThreadSafeContext failed.");
2668+
/* Wrap the LLVM context in a thread safe context. */
2669+
comp_ctx->orc_thread_safe_context =
2670+
LLVMOrcCreateNewThreadSafeContextFromLLVMContext(comp_ctx->context);
2671+
if (!comp_ctx->orc_thread_safe_context) {
2672+
aot_set_last_error(
2673+
"Create LLVM ThreadSafeContext from LLVMContext failed.");
26712674
goto fail;
26722675
}
26732676

core/iwasm/compilation/aot_llvm_extra.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,15 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
213213
#if LLVM_VERSION_MAJOR < 17
214214
PGO = PGOOptions("", "", "", PGOOptions::IRInstr);
215215
#else
216-
auto FS = vfs::getRealFileSystem();
217-
PGO = PGOOptions("", "", "", "", FS, PGOOptions::IRInstr);
216+
PGO = PGOOptions("", "", "", "", PGOOptions::IRInstr);
218217
#endif
219218
}
220219
else if (comp_ctx->use_prof_file) {
221220
#if LLVM_VERSION_MAJOR < 17
222221
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", PGOOptions::IRUse);
223222
#else
224-
auto FS = vfs::getRealFileSystem();
225-
PGO = PGOOptions(comp_ctx->use_prof_file, "", "", "", FS,
226-
PGOOptions::IRUse);
223+
PGO =
224+
PGOOptions(comp_ctx->use_prof_file, "", "", "", PGOOptions::IRUse);
227225
#endif
228226
}
229227

0 commit comments

Comments
 (0)