Skip to content

Commit 60596f1

Browse files
committed
jit: Supply LLVMGlobalGetValueType() for LLVM < 8.
Commit 37d5bab used this C API function while adding support for LLVM 16 and opaque pointers, but it's not available in LLVM 7 and older. Provide it in our own llvmjit_wrap.cpp. It just calls a C++ function that pre-dates LLVM 3.9, our minimum target. Back-patch to 12, like 37d5bab. Discussion: https://postgr.es/m/CA%2BhUKGKnLnJnWrkr%3D4mSGhE5FuTK55FY15uULR7%3Dzzc%3DwX4Nqw%40mail.gmail.com
1 parent 74d19ec commit 60596f1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/backend/jit/llvm/llvmjit_wrap.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,11 @@ LLVMGetFunctionType(LLVMValueRef r)
8888
{
8989
return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getFunctionType());
9090
}
91+
92+
#if LLVM_VERSION_MAJOR < 8
93+
LLVMTypeRef
94+
LLVMGlobalGetValueType(LLVMValueRef g)
95+
{
96+
return llvm::wrap(llvm::unwrap<llvm::GlobalValue>(g)->getValueType());
97+
}
98+
#endif

src/include/jit/llvmjit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ extern unsigned LLVMGetAttributeCountAtIndexPG(LLVMValueRef F, uint32 Idx);
141141
extern LLVMTypeRef LLVMGetFunctionReturnType(LLVMValueRef r);
142142
extern LLVMTypeRef LLVMGetFunctionType(LLVMValueRef r);
143143

144+
#if LLVM_MAJOR_VERSION < 8
145+
extern LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef g);
146+
#endif
147+
144148
#ifdef __cplusplus
145149
} /* extern "C" */
146150
#endif

0 commit comments

Comments
 (0)