jit: Supply LLVMGlobalGetValueType() for LLVM < 8.
authorThomas Munro <[email protected]>
Wed, 18 Oct 2023 14:01:55 +0000 (03:01 +1300)
committerThomas Munro <[email protected]>
Wed, 18 Oct 2023 14:04:00 +0000 (03:04 +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 6f00df59a03ebc6dc08bac725183797b12919890..e4f347a30ae2aee8c91cd557eb6f016b4473f260 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 a0e910323b8dfc01987569af295f79907f13b282..7d3f8b358fcc3bdc49f3689a9e8d5d80eb192f3f 100644 (file)
@@ -139,6 +139,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