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

Commit53c4dab

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 parent981292c commit53c4dab

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
@@ -18,6 +18,9 @@
1818
#include<llvm-c/BitWriter.h>
1919
#include<llvm-c/Core.h>
2020
#include<llvm-c/ExecutionEngine.h>
21+
#ifLLVM_VERSION_MAJOR>16
22+
#include<llvm-c/Transforms/PassBuilder.h>
23+
#endif
2124
#ifLLVM_VERSION_MAJOR>11
2225
#include<llvm-c/Orc.h>
2326
#include<llvm-c/OrcEE.h>
@@ -27,12 +30,14 @@
2730
#endif
2831
#include<llvm-c/Support.h>
2932
#include<llvm-c/Target.h>
33+
#ifLLVM_VERSION_MAJOR<17
3034
#include<llvm-c/Transforms/IPO.h>
3135
#include<llvm-c/Transforms/PassManagerBuilder.h>
3236
#include<llvm-c/Transforms/Scalar.h>
3337
#ifLLVM_VERSION_MAJOR>6
3438
#include<llvm-c/Transforms/Utils.h>
3539
#endif
40+
#endif
3641

3742
#include"jit/llvmjit.h"
3843
#include"jit/llvmjit_emit.h"
@@ -560,6 +565,7 @@ llvm_function_reference(LLVMJitContext *context,
560565
staticvoid
561566
llvm_optimize_module(LLVMJitContext*context,LLVMModuleRefmodule)
562567
{
568+
#ifLLVM_VERSION_MAJOR<17
563569
LLVMPassManagerBuilderRefllvm_pmb;
564570
LLVMPassManagerRefllvm_mpm;
565571
LLVMPassManagerRefllvm_fpm;
@@ -623,6 +629,31 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
623629
LLVMDisposePassManager(llvm_mpm);
624630

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

628659
/*

‎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