postgres.git / summary / log / commit / refs
commit cbdd09ae1b571e8ecd9dbc7cd9d43600f86b56f6
Author: Thomas Munro <tmunro@postgresql.org>
Date: Thu Jan 22 02:43:13 2026 +0000
First released in: 14.21, 15.16, 16.12, 17.8, 18.2
jit: Add missing inline pass for LLVM >= 17.
With LLVM >= 17, transform passes are provided as a string to
LLVMRunPasses. Only two strings were used: "default<O3>" and
"default<O0>,mem2reg".
With previous LLVM versions, an additional inline pass was added when
JIT inlining was enabled without optimization. With LLVM >= 17, the code
would go through llvm_inline, prepare the functions for inlining, but
the generated bitcode would be the same due to the missing inline pass.
This patch restores the previous behavior by adding an inline pass when
inlining is enabled but no optimization is done.
This fixes an oversight introduced by 76200e5e when support for LLVM 17
was added.
Backpatch-through: 14
Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Pierre Ducroquet <p.psql@pinaraf.info>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CAO6_XqrNjJnbn15ctPv7o4yEAT9fWa-dK15RSyun6QNw9YDtKg%40mail.gmail.com
src/backend/jit/llvm/llvmjit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 2ab3e8ba972..377b0f98e74 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -719,7 +719,11 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
if (context->base.flags & PGJIT_OPT3)
passes = "default<O3>";
+ else if (context->base.flags & PGJIT_INLINE)
+ /* if doing inlining, but no expensive optimization, add inline pass */
+ passes = "default<O0>,mem2reg,inline";
else
+ /* default<O0> includes always-inline pass */
passes = "default<O0>,mem2reg";
options = LLVMCreatePassBuilderOptions();
[parent: dcddd6987197]