]> gcc.gnu.org Git - gcc.git/commit
MIPS16: Mark $2/$3 as clobbered if GP is used
authorYunQiang Su <syq@gcc.gnu.org>
Tue, 28 May 2024 18:28:25 +0000 (02:28 +0800)
committerYunQiang Su <syq@gcc.gnu.org>
Thu, 30 May 2024 01:48:08 +0000 (09:48 +0800)
commit201cfa725587d13867b4dc25955434ebe90aff7b
treee4741d621e1a9b847d68c92703b7bed4adb894cd
parent8f6c56cda5b451e48913b73482c4129a9b6be46d
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 <mschiffer@universe-factory.net>
Origin-Patch-by: Felix Fietkau <nbd@nbd.name>.
gcc
* config/mips/mips.cc(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)
gcc/config/mips/mips.cc
This page took 0.064584 seconds and 5 git commands to generate.