https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106096
--- Comment #6 from Xi Ruoyao <xry111 at mengyan1223 dot wang> --- (In reply to chenglulu from comment #5) > Created attachment 53213 [details] > Modify the allocation order of caller saved registers. I think we need to completely prevent LARCH_PROLOGUE_TEMP from being used for sibcall: diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index 4d107a42209..f9de9a6e4fb 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -511,7 +511,7 @@ enum reg_class #define REG_CLASS_CONTENTS \ { \ { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ - { 0x001ff000, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \ + { 0x001fd000, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \ { 0xff9ffff0, 0x00000000, 0x00000000 }, /* JIRL_REGS */ \ { 0xfffffffc, 0x00000000, 0x00000000 }, /* CSR_REGS */ \ { 0xffffffff, 0x00000000, 0x00000000 }, /* GR_REGS */ \ Or even if LARCH_PROLOGUE_TEMP is less preferred, the register allocator may still use it for sibcall and blow something up again. (Above is for $r13, if you want to use $r12 instead as LARCH_PROLOGUE_TEMP you need to adjust it.)