jit: Changes for LLVM 17.
Changes required by https://llvm.org/docs/NewPassManager.html. Back-patch to 12, leaving the final release of 11 unchanged, consistent with earlier decision not to back-patch LLVM 16 support either. Author: Dmitry Dolgov <9erthalion6@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CA%2BhUKG%2BWXznXCyTgCADd%3DHWkP9Qksa6chd7L%3DGCnZo-MBgg9Lg%40mail.gmail.com
This commit is contained in:
parent
981292c19f
commit
53c4dabe18
@ -18,6 +18,9 @@
|
|||||||
#include <llvm-c/BitWriter.h>
|
#include <llvm-c/BitWriter.h>
|
||||||
#include <llvm-c/Core.h>
|
#include <llvm-c/Core.h>
|
||||||
#include <llvm-c/ExecutionEngine.h>
|
#include <llvm-c/ExecutionEngine.h>
|
||||||
|
#if LLVM_VERSION_MAJOR > 16
|
||||||
|
#include <llvm-c/Transforms/PassBuilder.h>
|
||||||
|
#endif
|
||||||
#if LLVM_VERSION_MAJOR > 11
|
#if LLVM_VERSION_MAJOR > 11
|
||||||
#include <llvm-c/Orc.h>
|
#include <llvm-c/Orc.h>
|
||||||
#include <llvm-c/OrcEE.h>
|
#include <llvm-c/OrcEE.h>
|
||||||
@ -27,12 +30,14 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <llvm-c/Support.h>
|
#include <llvm-c/Support.h>
|
||||||
#include <llvm-c/Target.h>
|
#include <llvm-c/Target.h>
|
||||||
|
#if LLVM_VERSION_MAJOR < 17
|
||||||
#include <llvm-c/Transforms/IPO.h>
|
#include <llvm-c/Transforms/IPO.h>
|
||||||
#include <llvm-c/Transforms/PassManagerBuilder.h>
|
#include <llvm-c/Transforms/PassManagerBuilder.h>
|
||||||
#include <llvm-c/Transforms/Scalar.h>
|
#include <llvm-c/Transforms/Scalar.h>
|
||||||
#if LLVM_VERSION_MAJOR > 6
|
#if LLVM_VERSION_MAJOR > 6
|
||||||
#include <llvm-c/Transforms/Utils.h>
|
#include <llvm-c/Transforms/Utils.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "jit/llvmjit.h"
|
#include "jit/llvmjit.h"
|
||||||
#include "jit/llvmjit_emit.h"
|
#include "jit/llvmjit_emit.h"
|
||||||
@ -560,6 +565,7 @@ llvm_function_reference(LLVMJitContext *context,
|
|||||||
static void
|
static void
|
||||||
llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
|
llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
|
||||||
{
|
{
|
||||||
|
#if LLVM_VERSION_MAJOR < 17
|
||||||
LLVMPassManagerBuilderRef llvm_pmb;
|
LLVMPassManagerBuilderRef llvm_pmb;
|
||||||
LLVMPassManagerRef llvm_mpm;
|
LLVMPassManagerRef llvm_mpm;
|
||||||
LLVMPassManagerRef llvm_fpm;
|
LLVMPassManagerRef llvm_fpm;
|
||||||
@ -623,6 +629,31 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
|
|||||||
LLVMDisposePassManager(llvm_mpm);
|
LLVMDisposePassManager(llvm_mpm);
|
||||||
|
|
||||||
LLVMPassManagerBuilderDispose(llvm_pmb);
|
LLVMPassManagerBuilderDispose(llvm_pmb);
|
||||||
|
#else
|
||||||
|
LLVMPassBuilderOptionsRef options;
|
||||||
|
LLVMErrorRef err;
|
||||||
|
const char *passes;
|
||||||
|
|
||||||
|
if (context->base.flags & PGJIT_OPT3)
|
||||||
|
passes = "default<O3>";
|
||||||
|
else
|
||||||
|
passes = "default<O0>,mem2reg";
|
||||||
|
|
||||||
|
options = LLVMCreatePassBuilderOptions();
|
||||||
|
|
||||||
|
#ifdef LLVM_PASS_DEBUG
|
||||||
|
LLVMPassBuilderOptionsSetDebugLogging(options, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LLVMPassBuilderOptionsSetInlinerThreshold(options, 512);
|
||||||
|
|
||||||
|
err = LLVMRunPasses(module, passes, NULL, options);
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
elog(ERROR, "failed to JIT module: %s", llvm_error_message(err));
|
||||||
|
|
||||||
|
LLVMDisposePassBuilderOptions(options);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,8 +23,14 @@ extern "C"
|
|||||||
|
|
||||||
#include <llvm/IR/Attributes.h>
|
#include <llvm/IR/Attributes.h>
|
||||||
#include <llvm/IR/Function.h>
|
#include <llvm/IR/Function.h>
|
||||||
|
#if LLVM_VERSION_MAJOR < 17
|
||||||
#include <llvm/MC/SubtargetFeature.h>
|
#include <llvm/MC/SubtargetFeature.h>
|
||||||
|
#endif
|
||||||
|
#if LLVM_VERSION_MAJOR > 16
|
||||||
|
#include <llvm/TargetParser/Host.h>
|
||||||
|
#else
|
||||||
#include <llvm/Support/Host.h>
|
#include <llvm/Support/Host.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "jit/llvmjit.h"
|
#include "jit/llvmjit.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user