https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118827
Bug ID: 118827 Summary: riscv scalar and vector are all saved when __attribute__((interrupt)) used Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fanghuaqi at vip dot qq.com Target Milestone: --- Hello, I met a strange issue when using __attribute__((interrupt)) to define a vector interrupt function, and found that when I call a function from this interrupt function, all scalar and vector registers are saved and restore when compiled with -march=rv64gcv -mabi=lp64d -O0 Code as below: #include <stdio.h> static unsigned int cnt; void delay(int ms) { for (volatile int i =0; i < ms; i ++) { asm volatile ("nop"); } } __attribute__((interrupt)) void test(void) { cnt ++; delay(cnt); } void main(void) { while (1) { printf("cnt is %d\n", cnt); } } godbolt link: https://godbolt.org/z/3hKaahYsP >From gcc 14.x, the vector registers are also saved and restored if I call a subfunction from interrupt function. How can I make this interrupt attribute marked function save less registers on stack, since sometimes the subfunction is really simple, but call it will cost a lot stack save and restore. Thanks for any input