Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7da915e

Browse files
committed
jit: Changes for LLVM 17.
Changes required byhttps://llvm.org/docs/NewPassManager.html.Back-patch to 12, leaving the final release of 11 unchanged, consistentwith 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
1 parentd701f0d commit7da915e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

‎src/backend/jit/llvm/llvmjit.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include<llvm-c/BitWriter.h>
3030
#include<llvm-c/Core.h>
3131
#include<llvm-c/ExecutionEngine.h>
32+
#ifLLVM_VERSION_MAJOR>16
33+
#include<llvm-c/Transforms/PassBuilder.h>
34+
#endif
3235
#ifLLVM_VERSION_MAJOR>11
3336
#include<llvm-c/Orc.h>
3437
#include<llvm-c/OrcEE.h>
@@ -38,12 +41,14 @@
3841
#endif
3942
#include<llvm-c/Support.h>
4043
#include<llvm-c/Target.h>
44+
#ifLLVM_VERSION_MAJOR<17
4145
#include<llvm-c/Transforms/IPO.h>
4246
#include<llvm-c/Transforms/PassManagerBuilder.h>
4347
#include<llvm-c/Transforms/Scalar.h>
4448
#ifLLVM_VERSION_MAJOR>6
4549
#include<llvm-c/Transforms/Utils.h>
4650
#endif
51+
#endif
4752

4853

4954
/* Handle of a module emitted via ORC JIT */
@@ -564,6 +569,7 @@ llvm_function_reference(LLVMJitContext *context,
564569
staticvoid
565570
llvm_optimize_module(LLVMJitContext*context,LLVMModuleRefmodule)
566571
{
572+
#ifLLVM_VERSION_MAJOR<17
567573
LLVMPassManagerBuilderRefllvm_pmb;
568574
LLVMPassManagerRefllvm_mpm;
569575
LLVMPassManagerRefllvm_fpm;
@@ -627,6 +633,31 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
627633
LLVMDisposePassManager(llvm_mpm);
628634

629635
LLVMPassManagerBuilderDispose(llvm_pmb);
636+
#else
637+
LLVMPassBuilderOptionsRefoptions;
638+
LLVMErrorReferr;
639+
constchar*passes;
640+
641+
if (context->base.flags&PGJIT_OPT3)
642+
passes="default<O3>";
643+
else
644+
passes="default<O0>,mem2reg";
645+
646+
options=LLVMCreatePassBuilderOptions();
647+
648+
#ifdefLLVM_PASS_DEBUG
649+
LLVMPassBuilderOptionsSetDebugLogging(options,1);
650+
#endif
651+
652+
LLVMPassBuilderOptionsSetInlinerThreshold(options,512);
653+
654+
err=LLVMRunPasses(module,passes,NULL,options);
655+
656+
if (err)
657+
elog(ERROR,"failed to JIT module: %s",llvm_error_message(err));
658+
659+
LLVMDisposePassBuilderOptions(options);
660+
#endif
630661
}
631662

632663
/*

‎src/backend/jit/llvm/llvmjit_wrap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ extern "C"
2323

2424
#include<llvm/IR/Attributes.h>
2525
#include<llvm/IR/Function.h>
26+
#if LLVM_VERSION_MAJOR < 17
2627
#include<llvm/MC/SubtargetFeature.h>
28+
#endif
29+
#if LLVM_VERSION_MAJOR > 16
30+
#include<llvm/TargetParser/Host.h>
31+
#else
2732
#include<llvm/Support/Host.h>
33+
#endif
2834

2935
#include"jit/llvmjit.h"
3036

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp