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

Commit7741850

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 parent60596f1 commit7741850

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"
@@ -561,6 +566,7 @@ llvm_function_reference(LLVMJitContext *context,
561566
staticvoid
562567
llvm_optimize_module(LLVMJitContext*context,LLVMModuleRefmodule)
563568
{
569+
#ifLLVM_VERSION_MAJOR<17
564570
LLVMPassManagerBuilderRefllvm_pmb;
565571
LLVMPassManagerRefllvm_mpm;
566572
LLVMPassManagerRefllvm_fpm;
@@ -624,6 +630,31 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
624630
LLVMDisposePassManager(llvm_mpm);
625631

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

629660
/*

‎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