From cb92520563834577d3afbbedcc0df4ee0aac3445 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 24 Aug 2018 10:20:55 -0700 Subject: [PATCH] LLVMJIT: LLVMGetHostCPUFeatures now is upstream, use LLMV version if available. Noticed thanks to buildfarm animal seawasp. Author: Andres Freund Backpatch: v11-, where LLVM based JIT compliation was introduced. --- config/llvm.m4 | 2 +- configure | 11 +++++++++++ src/backend/jit/llvm/llvmjit_wrap.cpp | 2 ++ src/include/jit/llvmjit.h | 2 ++ src/include/pg_config.h.in | 4 ++++ src/include/pg_config.h.win32 | 4 ++++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/config/llvm.m4 b/config/llvm.m4 index 09ff681228..7d81ac0b99 100644 --- a/config/llvm.m4 +++ b/config/llvm.m4 @@ -95,7 +95,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT], SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS" AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn], [], [], [[#include ]]) - AC_CHECK_DECLS([LLVMGetHostCPUName], [], [], [[#include ]]) + AC_CHECK_DECLS([LLVMGetHostCPUName, LLVMGetHostCPUFeatures], [], [], [[#include ]]) AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include ]]) CPPFLAGS="$SAVE_CPPFLAGS" diff --git a/configure b/configure index dd439ddd2f..2d36f1da30 100755 --- a/configure +++ b/configure @@ -5203,6 +5203,17 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_LLVMGETHOSTCPUNAME $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUFeatures" "ac_cv_have_decl_LLVMGetHostCPUFeatures" "#include +" +if test "x$ac_cv_have_decl_LLVMGetHostCPUFeatures" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_LLVMGETHOSTCPUFEATURES $ac_have_decl _ACEOF ac_fn_c_check_decl "$LINENO" "LLVMCreateGDBRegistrationListener" "ac_cv_have_decl_LLVMCreateGDBRegistrationListener" "#include diff --git a/src/backend/jit/llvm/llvmjit_wrap.cpp b/src/backend/jit/llvm/llvmjit_wrap.cpp index 5d1a17cde0..4d0c3f680f 100644 --- a/src/backend/jit/llvm/llvmjit_wrap.cpp +++ b/src/backend/jit/llvm/llvmjit_wrap.cpp @@ -32,6 +32,7 @@ char *LLVMGetHostCPUName(void) { #endif +#if defined(HAVE_DECL_LLVMGETHOSTCPUFEATURES) && !HAVE_DECL_LLVMGETHOSTCPUFEATURES char *LLVMGetHostCPUFeatures(void) { llvm::SubtargetFeatures Features; llvm::StringMap HostFeatures; @@ -42,3 +43,4 @@ char *LLVMGetHostCPUFeatures(void) { return strdup(Features.getString().c_str()); } +#endif diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h index b0093db49d..c81cff8a35 100644 --- a/src/include/jit/llvmjit.h +++ b/src/include/jit/llvmjit.h @@ -125,9 +125,11 @@ extern LLVMValueRef slot_compile_deform(struct LLVMJitContext *context, TupleDes extern char *LLVMGetHostCPUName(void); #endif +#if defined(HAVE_DECL_LLVMGETHOSTCPUFEATURES) && !HAVE_DECL_LLVMGETHOSTCPUFEATURES /** Get the host CPU features as a string. The result needs to be disposed with LLVMDisposeMessage. */ extern char *LLVMGetHostCPUFeatures(void); +#endif #ifdef __cplusplus } /* extern "C" */ diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 827574ee40..31bef2b7f5 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -142,6 +142,10 @@ `LLVMCreatePerfJITEventListener', and to 0 if you don't. */ #undef HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER +/* Define to 1 if you have the declaration of `LLVMGetHostCPUFeatures', and to + 0 if you don't. */ +#undef HAVE_DECL_LLVMGETHOSTCPUFEATURES + /* Define to 1 if you have the declaration of `LLVMGetHostCPUName', and to 0 if you don't. */ #undef HAVE_DECL_LLVMGETHOSTCPUNAME diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index 46ce49def2..436bc5f087 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -119,6 +119,10 @@ if you don't. */ #define HAVE_DECL_LLVMGETHOSTCPUNAME 0 +/* Define to 1 if you have the declaration of `LLVMGetHostCPUFeatures', and to 0 + if you don't. */ +#define HAVE_DECL_LLVMGETHOSTCPUFEATURES 0 + /* Define to 1 if you have the declaration of `LLVMOrcGetSymbolAddressIn', and to 0 if you don't. */ #define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN 0