#include
#include
#include
+#if LLVM_VERSION_MAJOR > 16
+#include
+#endif
#if LLVM_VERSION_MAJOR > 11
#include
#include
#endif
#include
#include
+#if LLVM_VERSION_MAJOR < 17
#include
#include
#include
#if LLVM_VERSION_MAJOR > 6
#include
#endif
+#endif
#include "jit/llvmjit.h"
#include "jit/llvmjit_emit.h"
static void
llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
{
+#if LLVM_VERSION_MAJOR < 17
LLVMPassManagerBuilderRef llvm_pmb;
LLVMPassManagerRef llvm_mpm;
LLVMPassManagerRef llvm_fpm;
LLVMDisposePassManager(llvm_mpm);
LLVMPassManagerBuilderDispose(llvm_pmb);
+#else
+ LLVMPassBuilderOptionsRef options;
+ LLVMErrorRef err;
+ const char *passes;
+
+ if (context->base.flags & PGJIT_OPT3)
+ passes = "default";
+ else
+ passes = "default,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
}
/*