https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112478
Kito Cheng <kito at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |kito at gcc dot gnu.org Last reconfirmed| |2023-11-14 Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |kito at gcc dot gnu.org --- Comment #6 from Kito Cheng <kito at gcc dot gnu.org> --- Oh, I guess I know what happened, I was confused by the commit you refer (but it's the root cause as you pointed out!) since I thought it may related to far jumps, but...actually not, the problem is something you describe in the title, and can be demonstrate by following small program: ```c void foo() { asm volatile("# " : ::"ra"); } ``` Before that commit: ```asm foo: addi sp,sp,-16 sd ra,8(sp) #APP # 2 "x.c" 1 # # 0 "" 2 #NO_APP ld ra,8(sp) addi sp,sp,16 jr ra ``` After that commit: ```asm foo: .LFB0: .cfi_startproc #APP # 2 "x.c" 1 # # 0 "" 2 #NO_APP ret ``` But why? because ra is accidentally become caller save register by following change: https://github.com/gcc-mirror/gcc/commit/71f906498ada9ec2780660b03bd6e27a93ad350c#diff-4083cffa971a940af1d435359a45dbfd4d5934384275b0ae5e0c71dece5fd866R331 So we no longer save it at prologue and epilogue longer...anyway I will take this and send a patch to fix that soon.