On 6/5/2026 2:46 AM, Monk Chiang wrote:
> The trampoline code generation for Zicfilp (CFI landing pads) uses
> three registers and includes a redundant LUI instruction.
>
> Before this patch, the trampoline code was:
>
>    lpad    0
>    auipc   t3, 0
>    l[wd]   t0, (target_function_offset - 4)(t3)
>    l[wd]   t3, (static_chain_offset - 4)(t3)
>    lui     t2, 0
>    jr      t0
>
> This uses three registers (t0, t2, t3) and has a redundant "lui t2, 0"
> instruction that is never used.
>
> After this patch, the trampoline code is:
>
>    lpad    0
>    auipc   t3, 0
>    l[wd]   t2, (target_function_offset - 4)(t3)
>    l[wd]   t3, (static_chain_offset - 4)(t3)
>    jr      t2
>    nop
>
> The optimization removes the redundant LUI instruction, uses only two
> registers (t2, t3), and adds a nop for proper 8-byte alignment to avoid
> -Wpadded warnings.
>
> gcc/
>
>       * config/riscv/riscv.cc (riscv_trampoline_init): Remove redundant
>       LUI instruction.
>
> gcc/testsuite/
>
>       * gcc.target/riscv/zicfilp-trampoline.c: New test.
So the new test is failing according to pre-commit CI.

https://github.com/ewlu/gcc-precommit-ci/issues/4654#issuecomment-4630529800



jeff

Reply via email to