Hi, Good catch, thanks for the patch.
On 16/01/26 06:10, Anthonin Bonnefoy wrote: > On Thu, Jan 15, 2026 at 2:51 PM Andres Freund <[email protected]> wrote: >> I'm strongly against removing the always inline pass, I see absolutely no >> reason for doing that. The whole point of always inline is that it happens >> unconditionally. It's not an expensive pass either. > > I've looked into more details on what was provided by 'default<O0>', > and it turns out it includes an always-inline pass[0]. This is also > visible when using debug-pass-manager: > > llvm-as < /dev/null | opt -disable-output --passes='default<O0>' > -debug-pass-manager > Running analysis: InnerAnalysisManagerProxy<FunctionAnalysisManager, > Module> on [module] > Running pass: AlwaysInlinerPass on [module] > Running analysis: ProfileSummaryAnalysis on [module] > Running pass: CoroConditionalWrapper on [module] > Running pass: VerifierPass on [module] > Running analysis: VerifierAnalysis on [module] > > With the pre-LLVM17 legacy pass manager, that doesn't seem to be the > case[1] (despite the confusing comment? Inliner is only set by > LLVMPassManagerBuilderUseInlinerWithThreshold). > > So, with 'default<O0>,mem2reg', we replicate the same behaviour as > pre-LLVM17 as it includes the always-inline pass. > > I've updated the patch to only add the inline pass when PGJIT_INLINE > is on. I've also added a comment to mention that always-inline is > included in O0. > > [0]: > https://github.com/llvm/llvm-project/blob/701040d48f759369dce755f185a21aa6b92ba3ae/llvm/lib/Passes/PassBuilderPipelines.cpp#L2360-L2365 > [1]: > https://github.com/llvm/llvm-project/blob/release/16.x/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L290-L313 I've tested this patch with LLVM 22 using the patches from [1] and it seems to me that it's working as expected. On master with jit_inline_above_cost=0 and jit_inline_above_cost=10000 I see the same bc: op.0.fetch: ; preds = %b.op.0.start call void @deform_0_1(ptr %v_scanslot) br label %b.op.1.start With v3 patch and with jit_inline_above_cost=0 it inline the deform function as expected: op.0.fetch: ; preds = %b.op.0.start %29 = getelementptr inbounds nuw %struct.TupleTableSlot, ptr %v_scanslot, i32 0, i32 5 %tts_values.i = load ptr, ptr %29, align 8 %30 = getelementptr inbounds nuw %struct.TupleTableSlot, ptr %v_scanslot, i32 0, i32 6 %tts_ISNULL.i = load ptr, ptr %30, align 8 %31 = getelementptr inbounds nuw %struct.TupleTableSlot, ptr %v_scanslot, i32 0, i32 1 ... [1] https://www.postgresql.org/message-id/flat/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com -- Matheus Alcantara EDB: https://www.enterprisedb.com
