https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125217
Bug ID: 125217
Summary: RISC-V: missing sspopchk when zicfiss + zcmp is
enabled
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: michiel at derhaeg dot be
Target Milestone: ---
Example: https://godbolt.org/z/nTPhj5Y8Y
int printf(const char *,...);
int printSomething(int arr[], int len) {
for (int i = 0; i < len; i++)
printf("Val[%d]: %d\n", i, arr[i]);
return len;
}
emits
.LC0:
.string "Val[%d]: %d\n"
printSomething:
sspush ra
cm.push {ra, s0-s1}, -32
cm.mvsa01 s1,s0
li a1,0
.L2:
blt a1,s0,.L3
mv a0,s0
cm.popret {ra, s0-s1}, 32
.L3:
slli a5,a1,2
add a5,s1,a5
lw a2,0(a5)
lla a0,.LC0
sw a1,12(sp)
call printf@plt
lw a1,12(sp)
addi a1,a1,1
j .L2
Looks like a easy fix in riscv_expand_epilogue.
Already made a fix, will submit it soon.