Add missing JIT inline pass for llvm>=17
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
From: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-01-14T08:02:16Z
Lists: pgsql-hackers
Attachments
- check_jit_code.sh (text/x-sh)
- v1-0001-Add-missing-JIT-inline-pass-for-llvm-17.patch (application/octet-stream) patch v1-0001
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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
jit: Add missing inline pass for LLVM >= 17.
- f1c6b153cabd 18.2 landed
- d0bb0e5b364f 17.8 landed
- 7600dc79c231 16.12 landed
- cbdd09ae1b57 15.16 landed
- de8081c30e5a 14.21 landed
- e5d99b4d9ef4 19 (unreleased) landed