| From: | Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Add missing JIT inline pass for llvm>=17 |
| Date: | 2026-01-14 08:02:16 |
| Message-ID: | CAO6_XqrNjJnbn15ctPv7o4yEAT9fWa-dK15RSyun6QNw9YDtKg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| check_jit_code.sh | text/x-sh | 665 bytes |
| v1-0001-Add-missing-JIT-inline-pass-for-llvm-17.patch | application/octet-stream | 1.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Alexandra Wang | 2026-01-14 07:58:21 | Re: SQL:2023 JSON simplified accessor support |