https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84790
--- Comment #21 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by YunQiang Su <s...@gcc.gnu.org>: https://gcc.gnu.org/g:1bc4a777b21ae36b116e1842b7c482340ec929ef commit r11-11457-g1bc4a777b21ae36b116e1842b7c482340ec929ef Author: YunQiang Su <s...@gcc.gnu.org> Date: Wed May 29 02:28:25 2024 +0800 MIPS16: Mark $2/$3 as clobbered if GP is used PR Target/84790. The gp init sequence li $2,%hi(_gp_disp) addiu $3,$pc,%lo(_gp_disp) sll $2,16 addu $2,$3 is generated directly in `mips_output_function_prologue`, and does not appear in the RTL. So the IRA/IPA passes are not aware that $2/$3 have been clobbered, so they may be used for cross (local) function call. Let's mark $2/$3 clobber both: - Just after the UNSPEC_GP RTL of a function; - Just after a function call. Reported-by: Matthias Schiffer <mschif...@universe-factory.net> Origin-Patch-by: Felix Fietkau <n...@nbd.name>. gcc * config/mips/mips.c(mips16_gp_pseudo_reg): Mark MIPS16_PIC_TEMP and MIPS_PROLOGUE_TEMP clobbered. (mips_emit_call_insn): Mark MIPS16_PIC_TEMP and MIPS_PROLOGUE_TEMP clobbered if MIPS16 and CALL_CLOBBERED_GP. (cherry picked from commit 915440eed21de367cb41857afb5273aff5bcb737)