On 2023-Oct-18, Thomas Munro wrote:
> jit: Support opaque pointers in LLVM 16.
>
> Remove use of LLVMGetElementType() and provide the type of all pointers
> to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
> versions[1].
>
> * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
I have LLVM 14 (whatever Debian ships[*]), and running headerscheck results
in a bunch of warnings from this:
In file included from /tmp/headerscheck.s89Gdv/test.c:2:
/pgsql/source/master/src/include/jit/llvmjit_emit.h: In function ‘l_call’:
/pgsql/source/master/src/include/jit/llvmjit_emit.h:141:9: warning:
‘LLVMBuildCall’ is deprecated [-Wdeprecated-declarations]
141 | return LLVMBuildCall(b, fn, args, nargs, name);
| ^~~~~~
In file included from /usr/include/llvm-c/Core.h:18,
from /pgsql/source/master/src/include/jit/llvmjit_emit.h:18:
/usr/include/llvm-c/Core.h:3991:1: note: declared here
3991 | LLVM_ATTRIBUTE_C_DEPRECATED(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
These warnings go away if I change the conditional from
LLVM_VERSION_MAJOR < 16 to 14.
Let's ... do that? As in the attached patch.
In 13, there's a comment about it being deprecated, but no macro to make
the compiler whine:
https://github.com/hdoc/llvm-project/blob/release/13.x/llvm/include/llvm-c/Core.h#L3953
This changed in 14:
https://github.com/hdoc/llvm-project/blob/release/14.x/llvm/include/llvm-c/Core.h#L3898
[*] apt policy llvm:
llvm:
Installed: 1:14.0-55.7~deb12u1
Candidate: 1:14.0-55.7~deb12u1
Version table:
*** 1:14.0-55.7~deb12u1 500
500 http://ftp.de.debian.org/debian bookworm/main amd64 Packages
100 /var/lib/dpkg/status
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
>From d151e2aa327e865f7c6f68dd0493b52ae1736f82 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <[email protected]>
Date: Mon, 6 Nov 2023 19:08:39 +0100
Subject: [PATCH] use non-deprecated LLVM functions starting with its 14, not
16
---
src/include/jit/llvmjit_emit.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/include/jit/llvmjit_emit.h b/src/include/jit/llvmjit_emit.h
index b1f0ea56c0..e140da2152 100644
--- a/src/include/jit/llvmjit_emit.h
+++ b/src/include/jit/llvmjit_emit.h
@@ -107,7 +107,7 @@ l_pbool_const(bool i)
static inline LLVMValueRef
l_struct_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, int32 idx, const char *name)
{
-#if LLVM_VERSION_MAJOR < 16
+#if LLVM_VERSION_MAJOR < 14
return LLVMBuildStructGEP(b, v, idx, "");
#else
return LLVMBuildStructGEP2(b, t, v, idx, "");
@@ -117,7 +117,7 @@ l_struct_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, int32 idx, const c
static inline LLVMValueRef
l_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, LLVMValueRef *indices, int32 nindices, const char *name)
{
-#if LLVM_VERSION_MAJOR < 16
+#if LLVM_VERSION_MAJOR < 14
return LLVMBuildGEP(b, v, indices, nindices, name);
#else
return LLVMBuildGEP2(b, t, v, indices, nindices, name);
@@ -127,7 +127,7 @@ l_gep(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, LLVMValueRef *indices, in
static inline LLVMValueRef
l_load(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, const char *name)
{
-#if LLVM_VERSION_MAJOR < 16
+#if LLVM_VERSION_MAJOR < 14
return LLVMBuildLoad(b, v, name);
#else
return LLVMBuildLoad2(b, t, v, name);
@@ -137,7 +137,7 @@ l_load(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef v, const char *name)
static inline LLVMValueRef
l_call(LLVMBuilderRef b, LLVMTypeRef t, LLVMValueRef fn, LLVMValueRef *args, int32 nargs, const char *name)
{
-#if LLVM_VERSION_MAJOR < 16
+#if LLVM_VERSION_MAJOR < 14
return LLVMBuildCall(b, fn, args, nargs, name);
#else
return LLVMBuildCall2(b, t, fn, args, nargs, name);
--
2.39.2