From 517fec2936644b81d8be9cf75611dcad5cfe33cb Mon Sep 17 00:00:00 2001
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Date: Thu, 15 Jan 2026 10:15:59 +0100
Subject: Remove always-inline pass for LLVM<17

For LLVM to be able to inline functions, the function needs to be
imported, as done within llvm_inline.

However, llvm_inline isn't called in the non-optimized case, meaning
external functions can't be inlined, even those tagged with
always-inline.

This patch removes the always-inline patch for LLVM<17 as it won't have
any effect.
---
 src/backend/jit/llvm/llvmjit.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 32b6125e812..54afd1f8c11 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -650,15 +650,11 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
 	LLVMDisposePassManager(llvm_fpm);
 
 	/*
-	 * Perform module level optimization. We do so even in the non-optimized
-	 * case, so always-inline functions etc get inlined. It's cheap enough.
+	 * Perform module level optimization.
 	 */
 	llvm_mpm = LLVMCreatePassManager();
 	LLVMPassManagerBuilderPopulateModulePassManager(llvm_pmb,
 													llvm_mpm);
-	/* always use always-inliner pass */
-	if (!(context->base.flags & PGJIT_OPT3))
-		LLVMAddAlwaysInlinerPass(llvm_mpm);
 	/* if doing inlining, but no expensive optimization, add inlining pass */
 	if (context->base.flags & PGJIT_INLINE
 		&& !(context->base.flags & PGJIT_OPT3))
-- 
2.51.0

