Skip to content

Commit 7f7b890

Browse files
committed
Support LLVM 21 in LLVMExtra
1 parent 90917c8 commit 7f7b890

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

deps/LLVMExtra/include/LLVMExtra.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
162162
#endif
163163

164164
// Constant data
165+
#if LLVM_VERSION_MAJOR < 21
165166
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data,
166167
unsigned NumElements);
168+
#endif
167169

168170
// Missing opaque pointer APIs
169171
#if LLVM_VERSION_MAJOR < 17
@@ -258,5 +260,9 @@ LLVMErrorRef LLVMRunJuliaPassesOnFunction(LLVMValueRef F, const char *Passes,
258260
// More DataLayout queries
259261
unsigned LLVMGlobalsAddressSpace(LLVMTargetDataRef TD);
260262

263+
#if LLVM_VERSION_MAJOR >= 21
264+
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx);
265+
#endif
266+
261267
LLVM_C_EXTERN_C_END
262268
#endif

deps/LLVMExtra/lib/Core.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,14 @@ void LLVMReplaceMDNodeOperandWith(LLVMValueRef V, unsigned Index,
569569
// Constant data
570570
//
571571

572+
#if LLVM_VERSION_MAJOR < 21
572573
LLVMValueRef LLVMConstDataArray(LLVMTypeRef ElementTy, const void *Data,
573574
unsigned NumElements) {
574575
StringRef S((const char *)Data,
575576
NumElements * unwrap(ElementTy)->getPrimitiveSizeInBits() / 8);
576577
return wrap(ConstantDataArray::getRaw(S, NumElements, unwrap(ElementTy)));
577578
}
579+
#endif
578580

579581

580582
//
@@ -807,3 +809,18 @@ LLVMContextRef LLVMGetBuilderContext(LLVMBuilderRef Builder) {
807809
unsigned LLVMGlobalsAddressSpace(LLVMTargetDataRef TD) {
808810
return unwrap(TD)->getDefaultGlobalsAddressSpace();
809811
}
812+
813+
#if LLVM_VERSION_MAJOR >= 21
814+
815+
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(orc::ThreadSafeContext, LLVMOrcThreadSafeContextRef)
816+
817+
//
818+
// Removed from LLVM and unsafe but it's only used to provide an unsafe API
819+
// on the julia side anyway
820+
//
821+
822+
LLVMContextRef LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx) {
823+
return wrap(unwrap(TSCtx)->withContextDo([] (LLVMContext *ctx) { return ctx; }));
824+
}
825+
826+
#endif

0 commit comments

Comments
 (0)