Re: LLVM JITLink attempt II (WIP)

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Gregory Burd <greg(at)burd(dot)me>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Subject: Re: LLVM JITLink attempt II (WIP)
Date: 2026-01-08 13:33:33
Message-ID: CAO6_Xqr1Rpm9fTrp+BUjfZ55WCkC9THoB3MyHz=995Hrd8VanQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Jan 6, 2026 at 1:09 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> jit_debugging_support may just be just a matter of calling
> LLVMOrcLLJITEnableDebugSupport()[1], though it looks like it might
> only work for ELF (the other interesting object format at this stage
> being macOS's MachO, and in the past/possible future AIX's COFF/XCOFF
> and eventually Windows COFF/PE), but I'm not sure. You can tell if
> it's working by making it crash/abort in JITed code and seeing if the
> stack is decodable by GDB I had been thinking we were going to have
> to write that function because I'd missed its arrival in LLVM 18[2],
> d'uh.

I've tested the patch while adding the call to
'LLVMOrcLLJITEnableDebugSupport(lljit);', and it works. I have full
backtraces with JIT function names:
* frame #0: 0x0000f4196f94a254 JIT(0xf4196f956000)`deform_1_2 + 28
frame #1: 0x0000f4196f94a14c JIT(0xf4196f956000)`evalexpr_1_1 + 172
frame #2: 0x0000bb2f132f3098
postgres`ExecEvalExprNoReturn(econtext=<unavailable>,
state=<unavailable>) at executor.h:423:13
frame #3: 0x0000bb2f132f3094
postgres`ExecEvalExprNoReturnSwitchContext(econtext=<unavailable>,
state=<unavailable>) at executor.h:464:2

> It sounds like we might need to wait for or write a similar
> function for perf support.

Yeah, there's no C api provided by LLVM yet. I've just opened a
tentative PR[1] to add it. With the modified LLVM and postgres calling
LLVMOrcLLJITEnablePerfSupport, I see the generated perf dumps in
~/.debug/jit/llvm-IR-jit-20260108-61640f/jit-38489.dump.
Though if I try to perf inject the dumps, I have the following errors
jitdump file contains invalid or unsupported flags 0xf5880666c26c
0x2b750 [0xa8]: failed to process type: 10 [Operation not permitted]
But that might be an issue with my setup, I would need to test it
further to understand the issue...

[1] https://github.com/llvm/llvm-project/pull/174973

Attachment Content-Type Size
v3-0001-jit-Use-JITLink-for-LLVM-22.patch application/octet-stream 3.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-01-08 13:34:57 Re: pg_upgrade: optimize replication slot caught-up check
Previous Message li carol 2026-01-08 13:31:49 回复: [PATCH] Expose checkpoint reason to completion log messages.