On 5/8/2026 12:27 PM, Michiel Derhaeg wrote:
Currently when -fcf-protection=return and zcmp are enabled this code is
generated:
sspush ra
cm.push {ra, s0-s1}, -32
..
cm.popret {ra, s0-s1}, 32
riscv_expand_epilogue will skip emitting sspopchk when cm.popret is
emitted. After this patch we will no longer emit cm.popret and instead
use cm.pop + sspopchk + a regular return:
sspush ra
cm.push {ra, s0-s1}, -32
..
cm.pop {ra, s0-s1}, 32
sspopchk ra
jr ra
Regtested for rv32g & rv64g.
PR target/125217
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_gen_multi_pop_insn): Rename variable.
(riscv_expand_epilogue): Don't emit cm.popret with shadow stack.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/ssp-zcmp.c: New test.
Thanks. I've pushed this to the trunk.
jeff