From e5d99b4d9ef4b92fb74f05bf783e06766bb661ee Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 22 Jan 2026 15:43:13 +1300 Subject: [PATCH] jit: Add missing inline pass for LLVM >= 17. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With LLVM >= 17, transform passes are provided as a string to LLVMRunPasses. Only two strings were used: "default" and "default,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 Reviewed-by: Thomas Munro Reviewed-by: Andreas Karlsson Reviewed-by: Andres Freund Reviewed-by: Álvaro Herrera Reviewed-by: Pierre Ducroquet Reviewed-by: Matheus Alcantara 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 8d009dd5cf7..2e8aa4749db 100644 --- a/src/backend/jit/llvm/llvmjit.c +++ b/src/backend/jit/llvm/llvmjit.c @@ -674,7 +674,11 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module) if (context->base.flags & PGJIT_OPT3) passes = "default"; + else if (context->base.flags & PGJIT_INLINE) + /* if doing inlining, but no expensive optimization, add inline pass */ + passes = "default,mem2reg,inline"; else + /* default includes always-inline pass */ passes = "default,mem2reg"; options = LLVMCreatePassBuilderOptions();