mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-21 03:13:05 +08:00
jit: Require at least LLVM 14, if enabled.
Remove support for LLVM versions 10-13. The default on all non-EOL'd OSes represented in our build farm will be at least LLVM 14 when PostgreSQL 18 ships. Author: Thomas Munro <thomas.munro@gmail.com> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/CA%2BhUKGLhNs5geZaVNj2EJ79Dx9W8fyWUU3HxcpZy55sMGcY%3DiA%40mail.gmail.com
This commit is contained in:
parent
1b4d52c355
commit
972c2cd288
@ -25,8 +25,8 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
|
||||
AC_MSG_ERROR([$LLVM_CONFIG does not work])
|
||||
fi
|
||||
# and whether the version is supported
|
||||
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 10) exit 1; else exit 0;}';then
|
||||
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required])
|
||||
if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 14) exit 1; else exit 0;}';then
|
||||
AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 14 is required])
|
||||
fi
|
||||
AC_MSG_NOTICE([using llvm $pgac_llvm_version])
|
||||
|
||||
|
4
configure
vendored
4
configure
vendored
@ -5072,8 +5072,8 @@ fi
|
||||
as_fn_error $? "$LLVM_CONFIG does not work" "$LINENO" 5
|
||||
fi
|
||||
# and whether the version is supported
|
||||
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 10) exit 1; else exit 0;}';then
|
||||
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 10 is required" "$LINENO" 5
|
||||
if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 14) exit 1; else exit 0;}';then
|
||||
as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 14 is required" "$LINENO" 5
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: using llvm $pgac_llvm_version" >&5
|
||||
$as_echo "$as_me: using llvm $pgac_llvm_version" >&6;}
|
||||
|
@ -936,7 +936,7 @@ build-postgresql:
|
||||
<acronym>JIT</acronym> compilation (see <xref linkend="jit"/>). This
|
||||
requires the <productname>LLVM</productname> library to be installed.
|
||||
The minimum required version of <productname>LLVM</productname> is
|
||||
currently 10.
|
||||
currently 14.
|
||||
</para>
|
||||
<para>
|
||||
<command>llvm-config</command><indexterm><primary>llvm-config</primary></indexterm>
|
||||
@ -2394,7 +2394,7 @@ ninja install
|
||||
<acronym>JIT</acronym> compilation (see <xref linkend="jit"/>).
|
||||
This requires the <productname>LLVM</productname> library to be
|
||||
installed. The minimum required version of
|
||||
<productname>LLVM</productname> is currently 10. Disabled by
|
||||
<productname>LLVM</productname> is currently 14. Disabled by
|
||||
default.
|
||||
</para>
|
||||
|
||||
|
@ -792,7 +792,7 @@ endif
|
||||
llvmopt = get_option('llvm')
|
||||
llvm = not_found_dep
|
||||
if add_languages('cpp', required: llvmopt, native: false)
|
||||
llvm = dependency('llvm', version: '>=10', method: 'config-tool', required: llvmopt)
|
||||
llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt)
|
||||
|
||||
if llvm.found()
|
||||
|
||||
|
@ -21,13 +21,9 @@
|
||||
#if LLVM_VERSION_MAJOR > 16
|
||||
#include <llvm-c/Transforms/PassBuilder.h>
|
||||
#endif
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
#include <llvm-c/Orc.h>
|
||||
#include <llvm-c/OrcEE.h>
|
||||
#include <llvm-c/LLJIT.h>
|
||||
#else
|
||||
#include <llvm-c/OrcBindings.h>
|
||||
#endif
|
||||
#include <llvm-c/Support.h>
|
||||
#include <llvm-c/Target.h>
|
||||
#if LLVM_VERSION_MAJOR < 17
|
||||
@ -50,13 +46,8 @@
|
||||
/* Handle of a module emitted via ORC JIT */
|
||||
typedef struct LLVMJitHandle
|
||||
{
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
LLVMOrcLLJITRef lljit;
|
||||
LLVMOrcResourceTrackerRef resource_tracker;
|
||||
#else
|
||||
LLVMOrcJITStackRef stack;
|
||||
LLVMOrcModuleHandle orc_handle;
|
||||
#endif
|
||||
} LLVMJitHandle;
|
||||
|
||||
|
||||
@ -103,14 +94,9 @@ static LLVMContextRef llvm_context;
|
||||
|
||||
|
||||
static LLVMTargetRef llvm_targetref;
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
static LLVMOrcThreadSafeContextRef llvm_ts_context;
|
||||
static LLVMOrcLLJITRef llvm_opt0_orc;
|
||||
static LLVMOrcLLJITRef llvm_opt3_orc;
|
||||
#else /* LLVM_VERSION_MAJOR > 11 */
|
||||
static LLVMOrcJITStackRef llvm_opt0_orc;
|
||||
static LLVMOrcJITStackRef llvm_opt3_orc;
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
|
||||
|
||||
static void llvm_release_context(JitContext *context);
|
||||
@ -124,10 +110,8 @@ static void llvm_set_target(void);
|
||||
static void llvm_recreate_llvm_context(void);
|
||||
static uint64_t llvm_resolve_symbol(const char *name, void *ctx);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
static LLVMOrcLLJITRef llvm_create_jit_instance(LLVMTargetMachineRef tm);
|
||||
static char *llvm_error_message(LLVMErrorRef error);
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
|
||||
/* ResourceOwner callbacks to hold JitContexts */
|
||||
static void ResOwnerReleaseJitContext(Datum res);
|
||||
@ -292,7 +276,6 @@ llvm_release_context(JitContext *context)
|
||||
{
|
||||
LLVMJitHandle *jit_handle = (LLVMJitHandle *) lfirst(lc);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
{
|
||||
LLVMOrcExecutionSessionRef ee;
|
||||
LLVMOrcSymbolStringPoolRef sp;
|
||||
@ -310,11 +293,6 @@ llvm_release_context(JitContext *context)
|
||||
sp = LLVMOrcExecutionSessionGetSymbolStringPool(ee);
|
||||
LLVMOrcSymbolStringPoolClearDeadEntries(sp);
|
||||
}
|
||||
#else /* LLVM_VERSION_MAJOR > 11 */
|
||||
{
|
||||
LLVMOrcRemoveModule(jit_handle->stack, jit_handle->orc_handle);
|
||||
}
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
|
||||
pfree(jit_handle);
|
||||
}
|
||||
@ -397,7 +375,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
|
||||
* to mangle here.
|
||||
*/
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
foreach(lc, context->handles)
|
||||
{
|
||||
LLVMJitHandle *handle = (LLVMJitHandle *) lfirst(lc);
|
||||
@ -427,19 +404,6 @@ llvm_get_function(LLVMJitContext *context, const char *funcname)
|
||||
if (addr)
|
||||
return (void *) (uintptr_t) addr;
|
||||
}
|
||||
#else
|
||||
foreach(lc, context->handles)
|
||||
{
|
||||
LLVMOrcTargetAddress addr;
|
||||
LLVMJitHandle *handle = (LLVMJitHandle *) lfirst(lc);
|
||||
|
||||
addr = 0;
|
||||
if (LLVMOrcGetSymbolAddressIn(handle->stack, &addr, handle->orc_handle, funcname))
|
||||
elog(ERROR, "failed to look up symbol \"%s\"", funcname);
|
||||
if (addr)
|
||||
return (void *) (uintptr_t) addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
elog(ERROR, "failed to JIT: %s", funcname);
|
||||
|
||||
@ -740,11 +704,7 @@ llvm_compile_module(LLVMJitContext *context)
|
||||
MemoryContext oldcontext;
|
||||
instr_time starttime;
|
||||
instr_time endtime;
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
LLVMOrcLLJITRef compile_orc;
|
||||
#else
|
||||
LLVMOrcJITStackRef compile_orc;
|
||||
#endif
|
||||
|
||||
if (context->base.flags & PGJIT_OPT3)
|
||||
compile_orc = llvm_opt3_orc;
|
||||
@ -801,7 +761,6 @@ llvm_compile_module(LLVMJitContext *context)
|
||||
* faster instruction selection mechanism is used.
|
||||
*/
|
||||
INSTR_TIME_SET_CURRENT(starttime);
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
{
|
||||
LLVMOrcThreadSafeModuleRef ts_module;
|
||||
LLVMErrorRef error;
|
||||
@ -829,16 +788,6 @@ llvm_compile_module(LLVMJitContext *context)
|
||||
|
||||
/* LLVMOrcLLJITAddLLVMIRModuleWithRT takes ownership of the module */
|
||||
}
|
||||
#else
|
||||
{
|
||||
handle->stack = compile_orc;
|
||||
if (LLVMOrcAddEagerlyCompiledIR(compile_orc, &handle->orc_handle, context->module,
|
||||
llvm_resolve_symbol, NULL))
|
||||
elog(ERROR, "failed to JIT module");
|
||||
|
||||
/* LLVMOrcAddEagerlyCompiledIR takes ownership of the module */
|
||||
}
|
||||
#endif
|
||||
|
||||
INSTR_TIME_SET_CURRENT(endtime);
|
||||
INSTR_TIME_ACCUM_DIFF(context->base.instr.emission_counter,
|
||||
@ -950,7 +899,6 @@ llvm_session_initialize(void)
|
||||
/* force symbols in main binary to be loaded */
|
||||
LLVMLoadLibraryPermanently(NULL);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
{
|
||||
llvm_ts_context = LLVMOrcCreateNewThreadSafeContext();
|
||||
|
||||
@ -960,31 +908,6 @@ llvm_session_initialize(void)
|
||||
llvm_opt3_orc = llvm_create_jit_instance(opt3_tm);
|
||||
opt3_tm = 0;
|
||||
}
|
||||
#else /* LLVM_VERSION_MAJOR > 11 */
|
||||
{
|
||||
llvm_opt0_orc = LLVMOrcCreateInstance(opt0_tm);
|
||||
llvm_opt3_orc = LLVMOrcCreateInstance(opt3_tm);
|
||||
|
||||
#if defined(HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER) && HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER
|
||||
if (jit_debugging_support)
|
||||
{
|
||||
LLVMJITEventListenerRef l = LLVMCreateGDBRegistrationListener();
|
||||
|
||||
LLVMOrcRegisterJITEventListener(llvm_opt0_orc, l);
|
||||
LLVMOrcRegisterJITEventListener(llvm_opt3_orc, l);
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER) && HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER
|
||||
if (jit_profiling_support)
|
||||
{
|
||||
LLVMJITEventListenerRef l = LLVMCreatePerfJITEventListener();
|
||||
|
||||
LLVMOrcRegisterJITEventListener(llvm_opt0_orc, l);
|
||||
LLVMOrcRegisterJITEventListener(llvm_opt3_orc, l);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
|
||||
on_proc_exit(llvm_shutdown, 0);
|
||||
|
||||
@ -1014,7 +937,6 @@ llvm_shutdown(int code, Datum arg)
|
||||
elog(PANIC, "LLVMJitContext in use count not 0 at exit (is %zu)",
|
||||
llvm_jit_context_in_use_count);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
{
|
||||
if (llvm_opt3_orc)
|
||||
{
|
||||
@ -1032,23 +954,6 @@ llvm_shutdown(int code, Datum arg)
|
||||
llvm_ts_context = NULL;
|
||||
}
|
||||
}
|
||||
#else /* LLVM_VERSION_MAJOR > 11 */
|
||||
{
|
||||
/* unregister profiling support, needs to be flushed to be useful */
|
||||
|
||||
if (llvm_opt3_orc)
|
||||
{
|
||||
LLVMOrcDisposeInstance(llvm_opt3_orc);
|
||||
llvm_opt3_orc = NULL;
|
||||
}
|
||||
|
||||
if (llvm_opt0_orc)
|
||||
{
|
||||
LLVMOrcDisposeInstance(llvm_opt0_orc);
|
||||
llvm_opt0_orc = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
}
|
||||
|
||||
/* helper for llvm_create_types, returning a function's return type */
|
||||
@ -1218,8 +1123,6 @@ llvm_resolve_symbol(const char *symname, void *ctx)
|
||||
return (uint64_t) addr;
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 11
|
||||
|
||||
static LLVMErrorRef
|
||||
llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
|
||||
LLVMOrcLookupStateRef *LookupState, LLVMOrcLookupKind Kind,
|
||||
@ -1238,9 +1141,7 @@ llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
|
||||
{
|
||||
const char *name = LLVMOrcSymbolStringPoolEntryStr(LookupSet[i].Name);
|
||||
|
||||
#if LLVM_VERSION_MAJOR > 12
|
||||
LLVMOrcRetainSymbolStringPoolEntry(LookupSet[i].Name);
|
||||
#endif
|
||||
symbols[i].Name = LookupSet[i].Name;
|
||||
symbols[i].Sym.Address = llvm_resolve_symbol(name, NULL);
|
||||
symbols[i].Sym.Flags.GenericFlags = LLVMJITSymbolGenericFlagsExported;
|
||||
@ -1369,8 +1270,6 @@ llvm_error_message(LLVMErrorRef error)
|
||||
return msg;
|
||||
}
|
||||
|
||||
#endif /* LLVM_VERSION_MAJOR > 11 */
|
||||
|
||||
/*
|
||||
* ResourceOwner callbacks
|
||||
*/
|
||||
|
@ -30,13 +30,7 @@ static std::new_handler old_new_handler = NULL;
|
||||
|
||||
static void fatal_system_new_handler(void);
|
||||
static void fatal_llvm_new_handler(void *user_data, const char *reason, bool gen_crash_diag);
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
static void fatal_llvm_new_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
|
||||
#endif
|
||||
static void fatal_llvm_error_handler(void *user_data, const char *reason, bool gen_crash_diag);
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
static void fatal_llvm_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@ -135,15 +129,6 @@ fatal_llvm_new_handler(void *user_data,
|
||||
errmsg("out of memory"),
|
||||
errdetail("While in LLVM: %s", reason)));
|
||||
}
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
static void
|
||||
fatal_llvm_new_handler(void *user_data,
|
||||
const std::string& reason,
|
||||
bool gen_crash_diag)
|
||||
{
|
||||
fatal_llvm_new_handler(user_data, reason.c_str(), gen_crash_diag);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
fatal_llvm_error_handler(void *user_data,
|
||||
@ -154,13 +139,3 @@ fatal_llvm_error_handler(void *user_data,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("fatal llvm error: %s", reason)));
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
static void
|
||||
fatal_llvm_error_handler(void *user_data,
|
||||
const std::string& reason,
|
||||
bool gen_crash_diag)
|
||||
{
|
||||
fatal_llvm_error_handler(user_data, reason.c_str(), gen_crash_diag);
|
||||
}
|
||||
#endif
|
||||
|
@ -594,10 +594,6 @@ function_inlinable(llvm::Function &F,
|
||||
if (F.materialize())
|
||||
elog(FATAL, "failed to materialize metadata");
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
#define hasFnAttr hasFnAttribute
|
||||
#endif
|
||||
|
||||
if (F.getAttributes().hasFnAttr(llvm::Attribute::NoInline))
|
||||
{
|
||||
ilog(DEBUG1, "ineligibile to import %s due to noinline",
|
||||
@ -858,9 +854,6 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
|
||||
llvm::Function *AF;
|
||||
llvm::BasicBlock *BB;
|
||||
llvm::CallInst *fwdcall;
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
llvm::Attribute inlineAttribute;
|
||||
#endif
|
||||
|
||||
AF = llvm::Function::Create(F->getFunctionType(),
|
||||
LinkageTypes::AvailableExternallyLinkage,
|
||||
@ -869,13 +862,7 @@ create_redirection_function(std::unique_ptr<llvm::Module> &importMod,
|
||||
|
||||
Builder.SetInsertPoint(BB);
|
||||
fwdcall = Builder.CreateCall(F, &*AF->arg_begin());
|
||||
#if LLVM_VERSION_MAJOR < 14
|
||||
inlineAttribute = llvm::Attribute::get(Context,
|
||||
llvm::Attribute::AlwaysInline);
|
||||
fwdcall->addAttribute(~0U, inlineAttribute);
|
||||
#else
|
||||
fwdcall->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#endif
|
||||
Builder.CreateRet(fwdcall);
|
||||
|
||||
return AF;
|
||||
|
@ -17,10 +17,6 @@ extern "C"
|
||||
}
|
||||
|
||||
#include <llvm-c/Core.h>
|
||||
|
||||
/* Avoid macro clash with LLVM's C++ headers */
|
||||
#undef Min
|
||||
|
||||
#include <llvm/IR/Function.h>
|
||||
|
||||
#include "jit/llvmjit.h"
|
||||
|
Loading…
Reference in New Issue
Block a user