Subject: Add missing JIT inline pass for llvm>=17

From: Anthonin Bonnefoy <[email-masked]>
Date: Wed, 14 Jan 2026 09:02:16 +0100

Hi,

While reviewing the llvm-22 patches[0], I've tried to trigger JIT
inlining using the provided check_jit_code.sh script. The script
generates bc for both jit_inline_above_cost=0 and
jit_inline_above_cost=100000 and compares the generated code.

However, the generated bitcode were more or less the same, the only
minor difference being the "inlining" version had additional strings.
I've made sure to install through autoconf as meson doesn't generate
and install bitcode files yet[1].

Debugging showed the code correctly going through llvm_inline and
correctly importing the functions in the module. However, I'm using
llvm21 and only the "default<O0>,mem2reg" passes are used, without any
inlining passes.

With llvm<17, the passes were configured as follow:
- No optimisation and no inlining: always-inline
- No optimisation and inlining: inline
- Optimisation: O3 (which includes inline)

The attached patch adds the inline pass when jit inlining is triggered
without optimisation, as was done with LLVM<17.

I didn't add the always-inline pass as I don't think this can have any
effect. From what I understand, the functions need to be imported
through llvm_inline for LLVM to be able to inline them. I've tested by
tagging int4mod as always inline, and the generated bc was still
calling the function despite the always-inline pass.

Regards,
Anthonin Bonnefoy

[0]: https://www.postgresql.org/message-id/flat/CA%2BhUKGJTumad75o8Zao-LFseEbt%3DenbUFCM7LZVV%3Dc8yg2i7dg%40mail.gmail.com
[1]: https://www.postgresql.org/message-id/flat/206b001d-1884-4081-bd02-bed5c92f02ba%40eisentraut.org