Re: [PATCH] llvmjit: always add the simplifycfg pass - Mailing list pgsql-hackers

From Matheus Alcantara
Subject Re: [PATCH] llvmjit: always add the simplifycfg pass
Date
Msg-id DFVDQRXJX7QW.KLYVOJSQW08Y@gmail.com
Whole thread Raw
In response to [PATCH] llvmjit: always add the simplifycfg pass  (Pierre Ducroquet <p.psql@pinaraf.info>)
Responses Re: [PATCH] llvmjit: always add the simplifycfg pass
List pgsql-hackers
Hi,

On 07/01/26 12:08, Pierre Ducroquet wrote:
> Hi
> 
> While reading the code generated by llvmjit, I realized the number of LLVM basic blocks used in tuple deforming was
directlyvisible in the generated assembly code with the following code:
 
> 0x723382b781c1: jmp 0x723382b781c3
> 0x723382b781c3: jmp 0x723382b781eb
> 0x723382b781c5: mov -0x20(%rsp),%rax
> 0x723382b781..: ... .....
> 0x723382b781e7: mov %cx,(%rax)
> 0x723382b781ea: ret
> 0x723382b781eb: jmp 0x723382b781ed
> 0x723382b781ed: jmp 0x723382b781ef
> 0x723382b781ef: jmp 0x723382b781f1
> 0x723382b781f1: jmp 0x723382b781f3
> 0x723382b781f3: mov -0x30(%rsp),%rax
> 0x723382b781..: ... ......
> 0x723382b78208: mov %rcx,(%rax)
> 0x723382b7820b: jmp 0x723382b781c5
> That's a lot of useless jumps, and LLVM has a specific pass to get rid of these. The attached patch modifies the
llvmjitcode to always call this pass, even below jit_optimize_above_cost.
 
> 
> On a basic benchmark (a simple select * from table where f = 42), this optimization saved 7ms of runtime while using
only0.1 ms of extra optimization time.
 
> 

The patch needs a rebase due to e5d99b4d9ef.

You've added the "simplifycfg" only when the "jit_optimize_above_cost"
is not triggered which will use the default<O0> and mem2reg passes, the
default<O3> pass already include "simplifycfg"?

With e5d99b4d9ef being committed, should we add "simplifycfg" when
PGJIT_INLINE bit is set since it also use the default<O0> and mem2reg
passes?

--
Matheus Alcantara
EDB: https://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: Race conditions in logical decoding
Next
From: Álvaro Herrera
Date:
Subject: Re: Race conditions in logical decoding