https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125217
--- Comment #2 from GCC Commits ---
The master branch has been updated by Jeff Law :
https://gcc.gnu.org/g:976bba902f3a8146b7ca5b352795977bc9179132
commit r17-425-g976bba902f3a8146b7ca5b352795977bc9179132
Author: Michiel Derhaeg
Date: Sat May 9 11:22:07 2026 -0600
[PATCH] RISC-V: Don't emit cm.popret when zcmp + zicfiss is enabled
[PR125217]
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.