1- From c72a1ba46ec85de784ccf3facd6f857c7ae0b79c Mon Sep 17 00:00:00 2001
1+ From 7f7b890cc786e3b33d2ac4c8c247b2770dfd13dc Mon Sep 17 00:00:00 2001
22From: Yichao Yu <
[email protected] >
33Date: Fri, 24 Oct 2025 09:43:36 -0400
4- Subject: [PATCH] Support LLVM 21 in LLVMExtra
4+ Subject: [PATCH 1/2 ] Support LLVM 21 in LLVMExtra
55
66---
7- deps/LLVMExtra/include/LLVMExtra.h | 2 ++
8- deps/LLVMExtra/lib/Core.cpp | 2 ++
9- 2 files changed, 4 insertions(+)
7+ deps/LLVMExtra/include/LLVMExtra.h | 6 ++++ ++
8+ deps/LLVMExtra/lib/Core.cpp | 17 +++++++++++++++ ++
9+ 2 files changed, 23 insertions(+)
1010
1111diff --git a/deps/LLVMExtra/include/LLVMExtra.h b/deps/LLVMExtra/include/LLVMExtra.h
12- index 0773ca49..5a0510b7 100644
12+ index 0773ca49..bcc40bfb 100644
1313--- a/deps/LLVMExtra/include/LLVMExtra.h
1414+++ b/deps/LLVMExtra/include/LLVMExtra.h
1515@@ -162,8 +162,10 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
@@ -23,8 +23,18 @@ index 0773ca49..5a0510b7 100644
2323
2424 // Missing opaque pointer APIs
2525 #if LLVM_VERSION_MAJOR < 17
26+ @@ -258,5 +260,9 @@ LLVMErrorRef LLVMRunJuliaPassesOnFunction(LLVMValueRef F, const char *Passes,
27+ // More DataLayout queries
28+ unsigned LLVMGlobalsAddressSpace(LLVMTargetDataRef TD);
29+
30+ + #if LLVM_VERSION_MAJOR >= 21
31+ + LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx);
32+ + #endif
33+ +
34+ LLVM_C_EXTERN_C_END
35+ #endif
2636diff --git a/deps/LLVMExtra/lib/Core.cpp b/deps/LLVMExtra/lib/Core.cpp
27- index 1d2311b7..778be33c 100644
37+ index 1d2311b7..d583052c 100644
2838--- a/deps/LLVMExtra/lib/Core.cpp
2939+++ b/deps/LLVMExtra/lib/Core.cpp
3040@@ -569,12 +569,14 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
@@ -42,6 +52,25 @@ index 1d2311b7..778be33c 100644
4252
4353
4454 //
55+ @@ -807,3 +809,18 @@ LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder) {
56+ unsigned LLVMGlobalsAddressSpace(LLVMTargetDataRef TD) {
57+ return unwrap(TD)->getDefaultGlobalsAddressSpace();
58+ }
59+ +
60+ + #if LLVM_VERSION_MAJOR >= 21
61+ +
62+ + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(orc::ThreadSafeContext, LLVMOrcThreadSafeContextRef)
63+ +
64+ + //
65+ + // Removed from LLVM and unsafe but it's only used to provide an unsafe API
66+ + // on the julia side anyway
67+ + //
68+ +
69+ + LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx) {
70+ + return wrap(unwrap(TSCtx)->withContextDo([] (LLVMContext *ctx) { return ctx; }));
71+ + }
72+ +
73+ + #endif
4574- -
46- 2.51.0
75+ 2.51.2
4776
0 commit comments