Skip to content

Commit 820b5af

Browse files
committed
jit: Require at least LLVM 10.
Remove support for older LLVM versions. The default on common software distributions will be at least LLVM 10 when PostgreSQL 17 ships. Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com
1 parent 7294396 commit 820b5af

File tree

11 files changed

+17
-243
lines changed

11 files changed

+17
-243
lines changed

config/llvm.m4

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
1313
AC_REQUIRE([AC_PROG_AWK])
1414
1515
AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config command])
16-
PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-7 llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9)
16+
PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10)
1717
1818
# no point continuing if llvm wasn't found
1919
if test -z "$LLVM_CONFIG"; then
@@ -25,14 +25,14 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
2525
AC_MSG_ERROR([$LLVM_CONFIG does not work])
2626
fi
2727
# and whether the version is supported
28-
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 4 || ([$]1 == 3 && [$]2 >= 9)) exit 1; else exit 0;}';then
29-
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required])
28+
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 10) exit 1; else exit 0;}';then
29+
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required])
3030
fi
3131
AC_MSG_NOTICE([using llvm $pgac_llvm_version])
3232
3333
# need clang to create some bitcode files
3434
AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode])
35-
PGAC_PATH_PROGS(CLANG, clang clang-7 clang-6.0 clang-5.0 clang-4.0 clang-3.9)
35+
PGAC_PATH_PROGS(CLANG, clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10)
3636
if test -z "$CLANG"; then
3737
AC_MSG_ERROR([clang not found, but required when compiling --with-llvm, specify with CLANG=])
3838
fi
@@ -115,8 +115,6 @@ AC_DEFUN([PGAC_CHECK_LLVM_FUNCTIONS],
115115
# Check which functionality is present
116116
SAVE_CPPFLAGS="$CPPFLAGS"
117117
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
118-
AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn], [], [], [[#include <llvm-c/OrcBindings.h>]])
119-
AC_CHECK_DECLS([LLVMGetHostCPUName, LLVMGetHostCPUFeatures], [], [], [[#include <llvm-c/TargetMachine.h>]])
120118
AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include <llvm-c/ExecutionEngine.h>]])
121119
CPPFLAGS="$SAVE_CPPFLAGS"
122120
])# PGAC_CHECK_LLVM_FUNCTIONS

configure

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5090,7 +5090,7 @@ if test "$with_llvm" = yes; then :
50905090

50915091

50925092
if test -z "$LLVM_CONFIG"; then
5093-
for ac_prog in llvm-config llvm-config-7 llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9
5093+
for ac_prog in llvm-config llvm-config-17 llvm-config-16 llvm-config-15 llvm-config-14 llvm-config-13 llvm-config-12 llvm-config-11 llvm-config-10
50945094
do
50955095
# Extract the first word of "$ac_prog", so it can be a program name with args.
50965096
set dummy $ac_prog; ac_word=$2
@@ -5154,16 +5154,16 @@ fi
51545154
as_fn_error $? "$LLVM_CONFIG does not work" "$LINENO" 5
51555155
fi
51565156
# and whether the version is supported
5157-
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 4 || ($1 == 3 && $2 >= 9)) exit 1; else exit 0;}';then
5158-
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required" "$LINENO" 5
5157+
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 10) exit 1; else exit 0;}';then
5158+
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required" "$LINENO" 5
51595159
fi
51605160
{ $as_echo "$as_me:${as_lineno-$LINENO}: using llvm $pgac_llvm_version" >&5
51615161
$as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}
51625162

51635163
# need clang to create some bitcode files
51645164

51655165
if test -z "$CLANG"; then
5166-
for ac_prog in clang clang-7 clang-6.0 clang-5.0 clang-4.0 clang-3.9
5166+
for ac_prog in clang clang-17 clang-16 clang-15 clang-14 clang-13 clang-12 clang-11 clang-10
51675167
do
51685168
# Extract the first word of "$ac_prog", so it can be a program name with args.
51695169
set dummy $ac_prog; ac_word=$2
@@ -16546,41 +16546,6 @@ if test "$with_llvm" = yes; then
1654616546
# Check which functionality is present
1654716547
SAVE_CPPFLAGS="$CPPFLAGS"
1654816548
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
16549-
ac_fn_c_check_decl "$LINENO" "LLVMOrcGetSymbolAddressIn" "ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" "#include <llvm-c/OrcBindings.h>
16550-
"
16551-
if test "x$ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" = xyes; then :
16552-
ac_have_decl=1
16553-
else
16554-
ac_have_decl=0
16555-
fi
16556-
16557-
cat >>confdefs.h <<_ACEOF
16558-
#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN $ac_have_decl
16559-
_ACEOF
16560-
16561-
ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUName" "ac_cv_have_decl_LLVMGetHostCPUName" "#include <llvm-c/TargetMachine.h>
16562-
"
16563-
if test "x$ac_cv_have_decl_LLVMGetHostCPUName" = xyes; then :
16564-
ac_have_decl=1
16565-
else
16566-
ac_have_decl=0
16567-
fi
16568-
16569-
cat >>confdefs.h <<_ACEOF
16570-
#define HAVE_DECL_LLVMGETHOSTCPUNAME $ac_have_decl
16571-
_ACEOF
16572-
ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUFeatures" "ac_cv_have_decl_LLVMGetHostCPUFeatures" "#include <llvm-c/TargetMachine.h>
16573-
"
16574-
if test "x$ac_cv_have_decl_LLVMGetHostCPUFeatures" = xyes; then :
16575-
ac_have_decl=1
16576-
else
16577-
ac_have_decl=0
16578-
fi
16579-
16580-
cat >>confdefs.h <<_ACEOF
16581-
#define HAVE_DECL_LLVMGETHOSTCPUFEATURES $ac_have_decl
16582-
_ACEOF
16583-
1658416549
ac_fn_c_check_decl "$LINENO" "LLVMCreateGDBRegistrationListener" "ac_cv_have_decl_LLVMCreateGDBRegistrationListener" "#include <llvm-c/ExecutionEngine.h>
1658516550
"
1658616551
if test "x$ac_cv_have_decl_LLVMCreateGDBRegistrationListener" = xyes; then :

doc/src/sgml/installation.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ build-postgresql:
936936
<acronym>JIT</acronym> compilation (see <xref linkend="jit"/>). This
937937
requires the <productname>LLVM</productname> library to be installed.
938938
The minimum required version of <productname>LLVM</productname> is
939-
currently 3.9.
939+
currently 10.
940940
</para>
941941
<para>
942942
<command>llvm-config</command><indexterm><primary>llvm-config</primary></indexterm>
@@ -2424,7 +2424,7 @@ ninja install
24242424
<acronym>JIT</acronym> compilation (see <xref linkend="jit"/>).
24252425
This requires the <productname>LLVM</productname> library to be
24262426
installed. The minimum required version of
2427-
<productname>LLVM</productname> is currently 3.9. Disabled by
2427+
<productname>LLVM</productname> is currently 10. Disabled by
24282428
default.
24292429
</para>
24302430

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ endif
757757
llvmopt = get_option('llvm')
758758
llvm = not_found_dep
759759
if add_languages('cpp', required: llvmopt, native: false)
760-
llvm = dependency('llvm', version: '>=3.9', method: 'config-tool', required: llvmopt)
760+
llvm = dependency('llvm', version: '>=10', method: 'config-tool', required: llvmopt)
761761

762762
if llvm.found()
763763

src/backend/jit/llvm/llvmjit.c

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
#include <llvm-c/Transforms/IPO.h>
3535
#include <llvm-c/Transforms/PassManagerBuilder.h>
3636
#include <llvm-c/Transforms/Scalar.h>
37-
#if LLVM_VERSION_MAJOR > 6
3837
#include <llvm-c/Transforms/Utils.h>
3938
#endif
40-
#endif
4139

4240
#include "jit/llvmjit.h"
4341
#include "jit/llvmjit_emit.h"
@@ -381,10 +379,7 @@ llvm_expand_funcname(struct LLVMJitContext *context, const char *basename)
381379
void *
382380
llvm_get_function(LLVMJitContext *context, const char *funcname)
383381
{
384-
#if LLVM_VERSION_MAJOR > 11 || \
385-
defined(HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
386382
ListCell *lc;
387-
#endif
388383

389384
llvm_assert_in_fatal_section();
390385

@@ -432,7 +427,7 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
432427
if (addr)
433428
return (void *) (uintptr_t) addr;
434429
}
435-
#elif defined(HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN) && HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
430+
#else
436431
foreach(lc, context->handles)
437432
{
438433
LLVMOrcTargetAddress addr;
@@ -444,28 +439,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
444439
if (addr)
445440
return (void *) (uintptr_t) addr;
446441
}
447-
#elif LLVM_VERSION_MAJOR < 5
448-
{
449-
LLVMOrcTargetAddress addr;
450-
451-
if ((addr = LLVMOrcGetSymbolAddress(llvm_opt0_orc, funcname)))
452-
return (void *) (uintptr_t) addr;
453-
if ((addr = LLVMOrcGetSymbolAddress(llvm_opt3_orc, funcname)))
454-
return (void *) (uintptr_t) addr;
455-
}
456-
#else
457-
{
458-
LLVMOrcTargetAddress addr;
459-
460-
if (LLVMOrcGetSymbolAddress(llvm_opt0_orc, &addr, funcname))
461-
elog(ERROR, "failed to look up symbol \"%s\"", funcname);
462-
if (addr)
463-
return (void *) (uintptr_t) addr;
464-
if (LLVMOrcGetSymbolAddress(llvm_opt3_orc, &addr, funcname))
465-
elog(ERROR, "failed to look up symbol \"%s\"", funcname);
466-
if (addr)
467-
return (void *) (uintptr_t) addr;
468-
}
469442
#endif
470443

471444
elog(ERROR, "failed to JIT: %s", funcname);
@@ -553,12 +526,8 @@ llvm_copy_attributes_at_index(LLVMValueRef v_from, LLVMValueRef v_to, uint32 ind
553526
int num_attributes;
554527
LLVMAttributeRef *attrs;
555528

556-
num_attributes = LLVMGetAttributeCountAtIndexPG(v_from, index);
529+
num_attributes = LLVMGetAttributeCountAtIndex(v_from, index);
557530

558-
/*
559-
* Not just for efficiency: LLVM <= 3.9 crashes when
560-
* LLVMGetAttributesAtIndex() is called for an index with 0 attributes.
561-
*/
562531
if (num_attributes == 0)
563532
return;
564533

@@ -852,7 +821,7 @@ llvm_compile_module(LLVMJitContext *context)
852821

853822
/* LLVMOrcLLJITAddLLVMIRModuleWithRT takes ownership of the module */
854823
}
855-
#elif LLVM_VERSION_MAJOR > 6
824+
#else
856825
{
857826
handle->stack = compile_orc;
858827
if (LLVMOrcAddEagerlyCompiledIR(compile_orc, &handle->orc_handle, context->module,
@@ -861,26 +830,6 @@ llvm_compile_module(LLVMJitContext *context)
861830

862831
/* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
863832
}
864-
#elif LLVM_VERSION_MAJOR > 4
865-
{
866-
LLVMSharedModuleRef smod;
867-
868-
smod = LLVMOrcMakeSharedModule(context->module);
869-
handle->stack = compile_orc;
870-
if (LLVMOrcAddEagerlyCompiledIR(compile_orc, &handle->orc_handle, smod,
871-
llvm_resolve_symbol, NULL))
872-
elog(ERROR, "failed to JIT module");
873-
874-
LLVMOrcDisposeSharedModuleRef(smod);
875-
}
876-
#else /* LLVM 4.0 and 3.9 */
877-
{
878-
handle->stack = compile_orc;
879-
handle->orc_handle = LLVMOrcAddEagerlyCompiledIR(compile_orc, context->module,
880-
llvm_resolve_symbol, NULL);
881-
882-
LLVMDisposeModule(context->module);
883-
}
884833
#endif
885834

886835
INSTR_TIME_SET_CURRENT(endtime);

src/backend/jit/llvm/llvmjit_error.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ static int fatal_new_handler_depth = 0;
2929
static std::new_handler old_new_handler = NULL;
3030

3131
static void fatal_system_new_handler(void);
32-
#if LLVM_VERSION_MAJOR > 4
3332
static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
3433
#if LLVM_VERSION_MAJOR < 14
3534
static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
3635
#endif
37-
#endif
3836
static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
3937
#if LLVM_VERSION_MAJOR < 14
4038
static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
@@ -65,9 +63,7 @@ llvm_enter_fatal_on_oom(void)
6563
if (fatal_new_handler_depth == 0)
6664
{
6765
old_new_handler = std::set_new_handler(fatal_system_new_handler);
68-
#if LLVM_VERSION_MAJOR > 4
6966
llvm::install_bad_alloc_error_handler(fatal_llvm_new_handler);
70-
#endif
7167
llvm::install_fatal_error_handler(fatal_llvm_error_handler);
7268
}
7369
fatal_new_handler_depth++;
@@ -83,9 +79,7 @@ llvm_leave_fatal_on_oom(void)
8379
if (fatal_new_handler_depth == 0)
8480
{
8581
std::set_new_handler(old_new_handler);
86-
#if LLVM_VERSION_MAJOR > 4
8782
llvm::remove_bad_alloc_error_handler();
88-
#endif
8983
llvm::remove_fatal_error_handler();
9084
}
9185
}
@@ -110,9 +104,7 @@ llvm_reset_after_error(void)
110104
if (fatal_new_handler_depth != 0)
111105
{
112106
std::set_new_handler(old_new_handler);
113-
#if LLVM_VERSION_MAJOR > 4
114107
llvm::remove_bad_alloc_error_handler();
115-
#endif
116108
llvm::remove_fatal_error_handler();
117109
}
118110
fatal_new_handler_depth = 0;
@@ -133,7 +125,6 @@ fatal_system_new_handler(void)
133125
errdetail("while in LLVM")));
134126
}
135127

136-
#if LLVM_VERSION_MAJOR > 4
137128
static void
138129
fatal_llvm_new_handler(void *user_data,
139130
const char *reason,
@@ -153,7 +144,6 @@ fatal_llvm_new_handler(void *user_data,
153144
fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
154145
}
155146
#endif
156-
#endif
157147

158148
static void
159149
fatal_llvm_error_handler(void *user_data,

src/backend/jit/llvm/llvmjit_expr.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,12 +2650,8 @@ create_LifetimeEnd(LLVMModuleRef mod)
26502650
LLVMTypeRef param_types[2];
26512651
LLVMContextRef lc;
26522652

2653-
/* LLVM 5+ has a variadic pointer argument */
2654-
#if LLVM_VERSION_MAJOR < 5
2655-
const char *nm = "llvm.lifetime.end";
2656-
#else
2653+
/* variadic pointer argument */
26572654
const char *nm = "llvm.lifetime.end.p0i8";
2658-
#endif
26592655

26602656
fn = LLVMGetNamedFunction(mod, nm);
26612657
if (fn)

0 commit comments

Comments
 (0)