Hi,

0001:  These days we handle LLVM API evolution with LLVM_VERSION_MAJOR
guards.  These GDB and Perf support probes escaped recent garbage
collection cycles by not being phrased like that.  Function probes are
generally better for cross-platform variations and library build
options that are exposed by function visibility, but in this case all
supported versions have the functions, even when the relevant feature
isn't enabled in LLVM.

0002:  On my FreeBSD box (and presumably any non-Linux system), if I
set jit_profiling_support=1 then LLVMCreatePerfJITEventListener() is a
dummy function that returns NULL and we crash.  The attached just
silently skips in that case.  If we raised an error instead I suppose
it would have to be FATAL given the call site in a callback invoked by
LLVM/C++.  We could work harder and teach the GUC to probe LLVM when
you try to turn it on, but apparently no one tried to turn on perf on
a system without perf in all these years...  Should the manual say
that it's only available on Linux?  Would it be reasonable to
additionally assume that __linux__ implies LLVM_USE_PERF and disable
the GUC otherwise?

(There are more kinds of profiling support available, which I might
learn more about as part of the JITLink work.)

0003:  While contemplating how close we are to an empty
llvmjit_wrap.cpp file, I considered whether the two wrappers added by
commit 37d5babb should be upstreamed, and then realised that this one
is not needed if you jump though one extra hoop.

0004:  I *think* the second one is redundant too: all the functions in
question are either global or we have a template function of the same
type that is.  From a spartan trail of bread crumbs[1][2] I realised
that we should be able to use LLVMGlobalGetValueType() instead.  make
check with passes with TEMP_CONFIG set to define jit_above_cost=0
against bleeding-edge LLVM built with
-DLLVM_USE_SANITIZER="Address;Undefined" and
-DLLVM_ENABLE_ASSERTIONS=ON.

[1] 
https://github.com/llvm/llvm-project/blob/06c8ee61ab80305be88380e6aa2f1b2fe32f859d/llvm/include/llvm-c/Core.h#L2672
[2] 
https://github.com/llvm/llvm-project/blob/06c8ee61ab80305be88380e6aa2f1b2fe32f859d/llvm/include/llvm/IR/Function.h#L210
From 7ccce43ae2cf465d7ebf37185dc1dd4f11ed8fb3 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Thu, 27 Nov 2025 22:57:38 +1300
Subject: [PATCH 1/6] jit: Drop redundant LLVM configure checks.

We currently require LLVM 14, so these checks for LLVM 9 functions are
always true.  We finished up having to test LLVM major versions directly
due to the nature of API changes, so this function-probing style wasn't
continued.
---
 config/llvm.m4                 | 17 -----------------
 configure                      | 32 --------------------------------
 configure.ac                   |  4 ----
 meson.build                    |  8 --------
 src/backend/jit/llvm/llvmjit.c |  5 -----
 src/include/pg_config.h.in     |  8 --------
 6 files changed, 74 deletions(-)

diff --git a/config/llvm.m4 b/config/llvm.m4
index 9d6fe8199e3..5d4f14cb900 100644
--- a/config/llvm.m4
+++ b/config/llvm.m4
@@ -101,20 +101,3 @@ dnl LLVM_CONFIG, CLANG are already output via AC_ARG_VAR
   AC_SUBST(LLVM_BINPATH)
 
 ])# PGAC_LLVM_SUPPORT
-
-
-# PGAC_CHECK_LLVM_FUNCTIONS
-# -------------------------
-#
-# Check presence of some optional LLVM functions.
-# (This shouldn't happen until we're ready to run AC_CHECK_DECLS tests;
-# because PGAC_LLVM_SUPPORT runs very early, it's not an appropriate place.)
-#
-AC_DEFUN([PGAC_CHECK_LLVM_FUNCTIONS],
-[
-  # Check which functionality is present
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
-  AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include <llvm-c/ExecutionEngine.h>]])
-  CPPFLAGS="$SAVE_CPPFLAGS"
-])# PGAC_CHECK_LLVM_FUNCTIONS
diff --git a/configure b/configure
index 3a0ed11fa8e..486456deee1 100755
--- a/configure
+++ b/configure
@@ -16475,38 +16475,6 @@ fi
   CPPFLAGS=$ac_save_CPPFLAGS
 fi
 
-if test "$with_llvm" = yes; then
-
-  # Check which functionality is present
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
-  ac_fn_c_check_decl "$LINENO" "LLVMCreateGDBRegistrationListener" "ac_cv_have_decl_LLVMCreateGDBRegistrationListener" "#include <llvm-c/ExecutionEngine.h>
-"
-if test "x$ac_cv_have_decl_LLVMCreateGDBRegistrationListener" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER $ac_have_decl
-_ACEOF
-ac_fn_c_check_decl "$LINENO" "LLVMCreatePerfJITEventListener" "ac_cv_have_decl_LLVMCreatePerfJITEventListener" "#include <llvm-c/ExecutionEngine.h>
-"
-if test "x$ac_cv_have_decl_LLVMCreatePerfJITEventListener" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER $ac_have_decl
-_ACEOF
-
-  CPPFLAGS="$SAVE_CPPFLAGS"
-
-fi
-
 # Lastly, restore full LIBS list and check for readline/libedit symbols
 LIBS="$LIBS_including_readline"
 
diff --git a/configure.ac b/configure.ac
index c2413720a18..624c3f28ddc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1938,10 +1938,6 @@ if test "$with_icu" = yes; then
   CPPFLAGS=$ac_save_CPPFLAGS
 fi
 
-if test "$with_llvm" = yes; then
-  PGAC_CHECK_LLVM_FUNCTIONS()
-fi
-
 # Lastly, restore full LIBS list and check for readline/libedit symbols
 LIBS="$LIBS_including_readline"
 
diff --git a/meson.build b/meson.build
index 6e7ddd74683..7011007e644 100644
--- a/meson.build
+++ b/meson.build
@@ -2665,14 +2665,6 @@ decl_checks += [
   ['memset_s', 'string.h', '#define __STDC_WANT_LIB_EXT1__ 1'],
 ]
 
-# Check presence of some optional LLVM functions.
-if llvm.found()
-  decl_checks += [
-    ['LLVMCreateGDBRegistrationListener', 'llvm-c/ExecutionEngine.h'],
-    ['LLVMCreatePerfJITEventListener', 'llvm-c/ExecutionEngine.h'],
-  ]
-endif
-
 foreach c : decl_checks
   func = c.get(0)
   header = c.get(1)
diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index e978b996bae..3d67bd6b9bc 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -1180,24 +1180,19 @@ llvm_create_object_layer(void *Ctx, LLVMOrcExecutionSessionRef ES, const char *T
 		LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager(ES);
 #endif
 
-
-#if defined(HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER) && HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER
 	if (jit_debugging_support)
 	{
 		LLVMJITEventListenerRef l = LLVMCreateGDBRegistrationListener();
 
 		LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
 	}
-#endif
 
-#if defined(HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER) && HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER
 	if (jit_profiling_support)
 	{
 		LLVMJITEventListenerRef l = LLVMCreatePerfJITEventListener();
 
 		LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
 	}
-#endif
 
 	return objlayer;
 }
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index b0b0cfdaf79..56915d2ef91 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -83,14 +83,6 @@
    don't. */
 #undef HAVE_DECL_F_FULLFSYNC
 
-/* Define to 1 if you have the declaration of
-   `LLVMCreateGDBRegistrationListener', and to 0 if you don't. */
-#undef HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER
-
-/* Define to 1 if you have the declaration of
-   `LLVMCreatePerfJITEventListener', and to 0 if you don't. */
-#undef HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER
-
 /* Define to 1 if you have the declaration of `memset_s', and to 0 if you
    don't. */
 #undef HAVE_DECL_MEMSET_S
-- 
2.51.2

From 1fa97971e0ff25276f6e5d71ce145dc1904993c6 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Fri, 28 Nov 2025 14:19:09 +1300
Subject: [PATCH 2/6] jit: Fix jit_profiling_support when not available.

On LLVM libraries built without LLVM_USE_PERF, which probably means all
non-Linux systems, LLVMCreatePerfJITEventListener() is a dummy function
that returns NULL.  Silently ignore the option, avoiding an assertion
failure or segmentation fault inside LLVM.

LLVMCreateGDBRegistrationListener() is called similarly but is always
available so needs no guard.

Backpatch-through: 14
---
 src/backend/jit/llvm/llvmjit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 3d67bd6b9bc..0e67267e807 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -1191,7 +1191,8 @@ llvm_create_object_layer(void *Ctx, LLVMOrcExecutionSessionRef ES, const char *T
 	{
 		LLVMJITEventListenerRef l = LLVMCreatePerfJITEventListener();
 
-		LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
+		if (l)
+			LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
 	}
 
 	return objlayer;
-- 
2.51.2

From 83974d87ad3dbaad5f801d8870fe4ea58f8f9885 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Fri, 28 Nov 2025 01:30:50 +1300
Subject: [PATCH 3/6] jit: Drop LLVMGetFunctionReturnType() wrapper.

Commit 37d5babb added this C wrapper function to reach the C++ function
llvm::Function::getReturnType(), but it's redundant since you can call
the existing LLVMGetReturnType() given a function type at the cost of
one extra call.
---
 src/backend/jit/llvm/llvmjit.c        | 4 ++--
 src/backend/jit/llvm/llvmjit_wrap.cpp | 6 ------
 src/include/jit/llvmjit.h             | 1 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 0e67267e807..6cd457e429a 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -521,7 +521,7 @@ llvm_copy_attributes(LLVMValueRef v_from, LLVMValueRef v_to)
 	/* copy function attributes */
 	llvm_copy_attributes_at_index(v_from, v_to, LLVMAttributeFunctionIndex);
 
-	if (LLVMGetTypeKind(LLVMGetFunctionReturnType(v_to)) != LLVMVoidTypeKind)
+	if (LLVMGetTypeKind(LLVMGetReturnType(LLVMGetFunctionType(v_to))) != LLVMVoidTypeKind)
 	{
 		/* and the return value attributes */
 		llvm_copy_attributes_at_index(v_from, v_to, LLVMAttributeReturnIndex);
@@ -960,7 +960,7 @@ load_return_type(LLVMModuleRef mod, const char *name)
 	if (!value)
 		elog(ERROR, "function %s is unknown", name);
 
-	typ = LLVMGetFunctionReturnType(value); /* in llvmjit_wrap.cpp */
+	typ = LLVMGetReturnType(LLVMGetFunctionType(value));
 
 	return typ;
 }
diff --git a/src/backend/jit/llvm/llvmjit_wrap.cpp b/src/backend/jit/llvm/llvmjit_wrap.cpp
index c31a57b8563..4033e730d7c 100644
--- a/src/backend/jit/llvm/llvmjit_wrap.cpp
+++ b/src/backend/jit/llvm/llvmjit_wrap.cpp
@@ -34,12 +34,6 @@ extern "C"
  * C-API extensions.
  */
 
-LLVMTypeRef
-LLVMGetFunctionReturnType(LLVMValueRef r)
-{
-	return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getReturnType());
-}
-
 LLVMTypeRef
 LLVMGetFunctionType(LLVMValueRef r)
 {
diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h
index b3c75022f55..1a8369005ef 100644
--- a/src/include/jit/llvmjit.h
+++ b/src/include/jit/llvmjit.h
@@ -139,7 +139,6 @@ extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDes
  * Error handling related functions.
  ****************************************************************************
  */
-extern LLVMTypeRef LLVMGetFunctionReturnType(LLVMValueRef r);
 extern LLVMTypeRef LLVMGetFunctionType(LLVMValueRef r);
 #ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER
 extern LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSafeSectionMemoryManager(LLVMOrcExecutionSessionRef ES);
-- 
2.51.2

From 5458f84cf92d8d454f1755b1d99fb763d7090f08 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Fri, 28 Nov 2025 02:16:29 +1300
Subject: [PATCH 4/6] jit: Drop LLVMGetFunctionType() wrapper.

Commit 37d5babb added this wrapper function to reach the C++ function
llvm::Function::getFunctionType(), but it turns out that we can just use
the existing LLVMGlobalGetValueType() function instead, at least for our
usage where the functions are all global or we have a reference function
that is global.
---
 src/backend/jit/llvm/llvmjit.c        | 10 +++++-----
 src/backend/jit/llvm/llvmjit_deform.c |  2 +-
 src/backend/jit/llvm/llvmjit_expr.c   | 26 +++++++++++++-------------
 src/backend/jit/llvm/llvmjit_wrap.cpp |  6 ------
 src/include/jit/llvmjit.h             |  1 -
 5 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 6cd457e429a..6a0db9de7c6 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -449,7 +449,7 @@ llvm_pg_var_func_type(const char *varname)
 	if (!v_srcvar)
 		elog(ERROR, "function %s not in llvmjit_types.c", varname);
 
-	typ = LLVMGetFunctionType(v_srcvar);
+	typ = LLVMGlobalGetValueType(v_srcvar);
 
 	return typ;
 }
@@ -479,7 +479,7 @@ llvm_pg_func(LLVMModuleRef mod, const char *funcname)
 
 	v_fn = LLVMAddFunction(mod,
 						   funcname,
-						   LLVMGetFunctionType(v_srcfn));
+						   LLVMGlobalGetValueType(v_srcfn));
 	llvm_copy_attributes(v_srcfn, v_fn);
 
 	return v_fn;
@@ -521,7 +521,7 @@ llvm_copy_attributes(LLVMValueRef v_from, LLVMValueRef v_to)
 	/* copy function attributes */
 	llvm_copy_attributes_at_index(v_from, v_to, LLVMAttributeFunctionIndex);
 
-	if (LLVMGetTypeKind(LLVMGetReturnType(LLVMGetFunctionType(v_to))) != LLVMVoidTypeKind)
+	if (LLVMGetTypeKind(LLVMGetReturnType(LLVMGlobalGetValueType(v_to))) != LLVMVoidTypeKind)
 	{
 		/* and the return value attributes */
 		llvm_copy_attributes_at_index(v_from, v_to, LLVMAttributeReturnIndex);
@@ -592,7 +592,7 @@ llvm_function_reference(LLVMJitContext *context,
 	if (v_fn != 0)
 		return v_fn;
 
-	v_fn = LLVMAddFunction(mod, funcname, LLVMGetFunctionType(AttributeTemplate));
+	v_fn = LLVMAddFunction(mod, funcname, LLVMGlobalGetValueType(AttributeTemplate));
 
 	return v_fn;
 }
@@ -960,7 +960,7 @@ load_return_type(LLVMModuleRef mod, const char *name)
 	if (!value)
 		elog(ERROR, "function %s is unknown", name);
 
-	typ = LLVMGetReturnType(LLVMGetFunctionType(value));
+	typ = LLVMGetReturnType(LLVMGlobalGetValueType(value));
 
 	return typ;
 }
diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c
index f500cbda893..f37c8141f55 100644
--- a/src/backend/jit/llvm/llvmjit_deform.c
+++ b/src/backend/jit/llvm/llvmjit_deform.c
@@ -351,7 +351,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc,
 		v_params[2] = l_int32_const(lc, natts);
 		f = llvm_pg_func(mod, "slot_getmissingattrs");
 		l_call(b,
-			   LLVMGetFunctionType(f), f,
+			   LLVMGlobalGetValueType(f), f,
 			   v_params, lengthof(v_params), "");
 		LLVMBuildBr(b, b_find_start);
 	}
diff --git a/src/backend/jit/llvm/llvmjit_expr.c b/src/backend/jit/llvm/llvmjit_expr.c
index ac88881e995..426ad8ee735 100644
--- a/src/backend/jit/llvm/llvmjit_expr.c
+++ b/src/backend/jit/llvm/llvmjit_expr.c
@@ -418,7 +418,7 @@ llvm_compile_expr(ExprState *state)
 						params[0] = v_slot;
 
 						l_call(b,
-							   LLVMGetFunctionType(l_jit_deform),
+							   LLVMGlobalGetValueType(l_jit_deform),
 							   l_jit_deform,
 							   params, lengthof(params), "");
 					}
@@ -1208,7 +1208,7 @@ llvm_compile_expr(ExprState *state)
 					v_params[1] = l_ptr_const(op, l_ptr(StructExprEvalStep));
 					v_params[2] = v_econtext;
 					l_call(b,
-						   LLVMGetFunctionType(ExecEvalSubroutineTemplate),
+						   LLVMGlobalGetValueType(ExecEvalSubroutineTemplate),
 						   v_func,
 						   v_params, lengthof(v_params), "");
 
@@ -1236,7 +1236,7 @@ llvm_compile_expr(ExprState *state)
 					v_params[1] = l_ptr_const(op, l_ptr(StructExprEvalStep));
 					v_params[2] = v_econtext;
 					v_ret = l_call(b,
-								   LLVMGetFunctionType(ExecEvalBoolSubroutineTemplate),
+								   LLVMGlobalGetValueType(ExecEvalBoolSubroutineTemplate),
 								   v_func,
 								   v_params, lengthof(v_params), "");
 					v_ret = LLVMBuildZExt(b, v_ret, TypeStorageBool, "");
@@ -1263,7 +1263,7 @@ llvm_compile_expr(ExprState *state)
 					v_params[1] = l_ptr_const(op, l_ptr(StructExprEvalStep));
 					v_params[2] = v_econtext;
 					l_call(b,
-						   LLVMGetFunctionType(ExecEvalSubroutineTemplate),
+						   LLVMGlobalGetValueType(ExecEvalSubroutineTemplate),
 						   v_func,
 						   v_params, lengthof(v_params), "");
 
@@ -1430,7 +1430,7 @@ llvm_compile_expr(ExprState *state)
 								   l_funcnullp(b, v_fcinfo_out, 0));
 					/* and call output function (can never return NULL) */
 					v_output = l_call(b,
-									  LLVMGetFunctionType(v_fn_out),
+									  LLVMGlobalGetValueType(v_fn_out),
 									  v_fn_out, &v_fcinfo_out,
 									  1, "funccall_coerce_out");
 					LLVMBuildBr(b, b_input);
@@ -1487,7 +1487,7 @@ llvm_compile_expr(ExprState *state)
 					LLVMBuildStore(b, l_sbool_const(0), v_fcinfo_in_isnullp);
 					/* and call function */
 					v_retval = l_call(b,
-									  LLVMGetFunctionType(v_fn_in),
+									  LLVMGlobalGetValueType(v_fn_in),
 									  v_fn_in, &v_fcinfo_in, 1,
 									  "funccall_iocoerce_in");
 
@@ -2854,7 +2854,7 @@ llvm_compile_expr(ExprState *state)
 						v_fn = llvm_pg_func(mod, "ExecAggCopyTransValue");
 						v_newval =
 							l_call(b,
-								   LLVMGetFunctionType(v_fn),
+								   LLVMGlobalGetValueType(v_fn),
 								   v_fn,
 								   params, lengthof(params),
 								   "");
@@ -2893,7 +2893,7 @@ llvm_compile_expr(ExprState *state)
 					v_args[0] = l_ptr_const(aggstate, l_ptr(StructAggState));
 					v_args[1] = l_ptr_const(pertrans, l_ptr(StructAggStatePerTransData));
 
-					v_ret = l_call(b, LLVMGetFunctionType(v_fn), v_fn, v_args, 2, "");
+					v_ret = l_call(b, LLVMGlobalGetValueType(v_fn), v_fn, v_args, 2, "");
 					v_ret = LLVMBuildZExt(b, v_ret, TypeStorageBool, "");
 
 					LLVMBuildCondBr(b,
@@ -2917,7 +2917,7 @@ llvm_compile_expr(ExprState *state)
 					v_args[0] = l_ptr_const(aggstate, l_ptr(StructAggState));
 					v_args[1] = l_ptr_const(pertrans, l_ptr(StructAggStatePerTransData));
 
-					v_ret = l_call(b, LLVMGetFunctionType(v_fn), v_fn, v_args, 2, "");
+					v_ret = l_call(b, LLVMGlobalGetValueType(v_fn), v_fn, v_args, 2, "");
 					v_ret = LLVMBuildZExt(b, v_ret, TypeStorageBool, "");
 
 					LLVMBuildCondBr(b,
@@ -3025,7 +3025,7 @@ BuildV1Call(LLVMJitContext *context, LLVMBuilderRef b,
 									"v_fcinfo_isnull");
 	LLVMBuildStore(b, l_sbool_const(0), v_fcinfo_isnullp);
 
-	v_retval = l_call(b, LLVMGetFunctionType(AttributeTemplate), v_fn, &v_fcinfo, 1, "funccall");
+	v_retval = l_call(b, LLVMGlobalGetValueType(AttributeTemplate), v_fn, &v_fcinfo, 1, "funccall");
 
 	if (v_fcinfo_isnull)
 		*v_fcinfo_isnull = l_load(b, TypeStorageBool, v_fcinfo_isnullp, "");
@@ -3040,11 +3040,11 @@ BuildV1Call(LLVMJitContext *context, LLVMBuilderRef b,
 
 		params[0] = l_int64_const(lc, sizeof(NullableDatum) * fcinfo->nargs);
 		params[1] = l_ptr_const(fcinfo->args, l_ptr(LLVMInt8TypeInContext(lc)));
-		l_call(b, LLVMGetFunctionType(v_lifetime), v_lifetime, params, lengthof(params), "");
+		l_call(b, LLVMGlobalGetValueType(v_lifetime), v_lifetime, params, lengthof(params), "");
 
 		params[0] = l_int64_const(lc, sizeof(fcinfo->isnull));
 		params[1] = l_ptr_const(&fcinfo->isnull, l_ptr(LLVMInt8TypeInContext(lc)));
-		l_call(b, LLVMGetFunctionType(v_lifetime), v_lifetime, params, lengthof(params), "");
+		l_call(b, LLVMGlobalGetValueType(v_lifetime), v_lifetime, params, lengthof(params), "");
 	}
 
 	return v_retval;
@@ -3076,7 +3076,7 @@ build_EvalXFuncInt(LLVMBuilderRef b, LLVMModuleRef mod, const char *funcname,
 	for (int i = 0; i < nargs; i++)
 		params[argno++] = v_args[i];
 
-	v_ret = l_call(b, LLVMGetFunctionType(v_fn), v_fn, params, argno, "");
+	v_ret = l_call(b, LLVMGlobalGetValueType(v_fn), v_fn, params, argno, "");
 
 	pfree(params);
 
diff --git a/src/backend/jit/llvm/llvmjit_wrap.cpp b/src/backend/jit/llvm/llvmjit_wrap.cpp
index 4033e730d7c..0dd311c59df 100644
--- a/src/backend/jit/llvm/llvmjit_wrap.cpp
+++ b/src/backend/jit/llvm/llvmjit_wrap.cpp
@@ -34,12 +34,6 @@ extern "C"
  * C-API extensions.
  */
 
-LLVMTypeRef
-LLVMGetFunctionType(LLVMValueRef r)
-{
-	return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getFunctionType());
-}
-
 #ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ExecutionSession, LLVMOrcExecutionSessionRef)
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ObjectLayer, LLVMOrcObjectLayerRef);
diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h
index 1a8369005ef..d03d508add5 100644
--- a/src/include/jit/llvmjit.h
+++ b/src/include/jit/llvmjit.h
@@ -139,7 +139,6 @@ extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDes
  * Error handling related functions.
  ****************************************************************************
  */
-extern LLVMTypeRef LLVMGetFunctionType(LLVMValueRef r);
 #ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER
 extern LLVMOrcObjectLayerRef LLVMOrcCreateRTDyldObjectLinkingLayerWithSafeSectionMemoryManager(LLVMOrcExecutionSessionRef ES);
 #endif
-- 
2.51.2

Reply via email to