]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
jit: Supply LLVMGlobalGetValueType() for LLVM < 8.
authorThomas Munro <tmunro@postgresql.org>
Wed, 18 Oct 2023 14:01:55 +0000 (03:01 +1300)
committerThomas Munro <tmunro@postgresql.org>
Wed, 18 Oct 2023 14:03:46 +0000 (03:03 +1300)
Commit 37d5babb 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 37d5babb.

Discussion: https://postgr.es/m/CA%2BhUKGKnLnJnWrkr%3D4mSGhE5FuTK55FY15uULR7%3Dzzc%3DwX4Nqw%40mail.gmail.com

src/backend/jit/llvm/llvmjit_wrap.cpp
src/include/jit/llvmjit.h

index ffda94a9938cd873a6259c13073d21fccb877b60..8008b9abd062e30d49888d069ac37b712f8bf0d2 100644 (file)
@@ -88,3 +88,11 @@ LLVMGetFunctionType(LLVMValueRef r)
 {
        return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getFunctionType());
 }
+
+#if LLVM_VERSION_MAJOR < 8
+LLVMTypeRef
+LLVMGlobalGetValueType(LLVMValueRef g)
+{
+       return llvm::wrap(llvm::unwrap<llvm::GlobalValue>(g)->getValueType());
+}
+#endif
index ffc2307ee146e02ccca4bce2d40a85956187a4ef..60cb5d51f5ae25aef6246eda5971e7c6d40031ee 100644 (file)
@@ -140,6 +140,10 @@ extern unsigned LLVMGetAttributeCountAtIndexPG(LLVMValueRef F, uint32 Idx);
 extern LLVMTypeRef LLVMGetFunctionReturnType(LLVMValueRef r);
 extern LLVMTypeRef LLVMGetFunctionType(LLVMValueRef r);
 
+#if LLVM_MAJOR_VERSION < 8
+extern LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef g);
+#endif
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif