Re: LLVM 22

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: LLVM 22
Date: 2026-01-05 23:50:38
Message-ID: CA+hUKGLNXakunn_FRe2ouy3G_5W-7sTCj2bz_ES1H=jhoHGsKQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 6, 2026 at 10:56 AM Matheus Alcantara
<matheusssilv97(at)gmail(dot)com> wrote:
> On Fri Jan 2, 2026 at 11:02 PM -03, Thomas Munro wrote:
> > Intrinsic has incorrect argument type!
> > ptr @llvm.lifetime.end.p0
> > Intrinsic has incorrect argument type!
> > ptr @llvm.lifetime.end.p0
> > 2026-01-02 17:28:31.394 NZDT client backend[42798] pg_regress/boolean
> > FATAL: fatal llvm error: Broken module found, compilation aborted!
> >
> I've managed to reproduce this using LLVM 22.

Thanks for testing!

> > Here's a potential minimal fix. I haven't yet proven that the
> > optimisation is still working as expected. Probably need to compile
> > an expression that calls an inlined function and then a non-inlined
> > function with jit_dump_bitcode=true, then find the right XXX.bc file
> > under pgdata, llvm-dis XXX.bc, llc XXX.ll, then visually inspect XXX.s
> > with enough caffeine to confirm that it's not spilling something (ie
> > store instructions) where previously it didn't, but I wanted to post
> > what I had so far to see if anyone has a better idea or an easy way to
> > test it...
> >
> I'm not super familiar with reading assembly code but I tried my best to
> inspect the LLVM 22 and LLVM 21 outputs and if I understood correctly I
> think that 0002 is working as expected.

Cool. And as another sanity test, if you comment out the new poison
code so that we don't try to prevent unwanted spills/stores, can you
see any?

> I've noticed a reduction on some instructions when using LLVM 22 with
> the 0002 patch compared with LLVM 21. For example, here we needed less
> instructions to set up the registers:
>
> LLVM 22:
> LBB2_8: ; %b.op.1.start
> mov x20, #40824 ; =0x9f78
> movk x20, #19456, lsl #16
> movk x20, #1, lsl #32
> ldr x8, [x23]
> ldrb w9, [x24]
> str x8, [x20, #152]
> strb w9, [x20, #160]
>
> LLVM 21:
> LBB2_8: ; %b.op.1.start
> mov x25, #25352 ; =0x6308
> movk x25, #2946, lsl #16
> movk x25, #1, lsl #32
> mov x20, #23533 ; =0x5bed
> movk x20, #2946, lsl #16
> movk x20, #1, lsl #32
> ldr x8, [x23]
> ldrb w9, [x24]
> stur x8, [x25, #-248]
> sturb w9, [x25, #-240]
>
> I've also noticed that the generated assembly code for LLVM 22 use the
> str and strb instructions instead of stur and sturb in some cases, which
> according to IA is an improvement but unfortunately I did not find any
> reference to prove this, sorry.

Interesting.

In response to

  • Re: LLVM 22 at 2026-01-05 21:56:10 from Matheus Alcantara

Responses

  • Re: LLVM 22 at 2026-01-06 18:35:06 from Matheus Alcantara

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-01-05 23:51:07 Re: Fix incorrect buffer lock description in pg_visibility comment
Previous Message Niyaz Hazigaleyev 2026-01-05 23:50:30 Re: [PATCH] meson: Update meson to enable building postgres as a subproject