mips.c (mips_cfun_call_saved_reg_p): Handle global registers.
authorRichard Sandiford <rdsandiford@googlemail.com>
Sun, 17 Apr 2011 17:29:52 +0000 (17:29 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sun, 17 Apr 2011 17:29:52 +0000 (17:29 +0000)
gcc/
* config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global
registers.

gcc/testsuite/
* gcc.target/mips/reg-var-1.c: New test.

From-SVN: r172616

gcc/ChangeLog
gcc/config/mips/mips.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/reg-var-1.c [new file with mode: 0644]

index b6d583bc195907e1db2b5d8149dcd3ac5ed516e4..4212388a4b4034fada71b0f4d13924481f23d9fc 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-17  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global
+       registers.
+
 2011-04-17  Jan Hubicka  <jh@suse.cz>
 
        * cgrpah.h (struct cgraph_node): Remove finalized_by_frontend.
index f65964b63e8a20af2a2671267dc2ef74afb4d0b6..e075c4f26485355ae66baa3a8f51e1c0759d0877 100644 (file)
@@ -9097,6 +9097,11 @@ mips_interrupt_extra_call_saved_reg_p (unsigned int regno)
 static bool
 mips_cfun_call_saved_reg_p (unsigned int regno)
 {
+  /* If the user makes an ordinarily-call-saved register global,
+     that register is no longer call-saved.  */
+  if (global_regs[regno])
+    return false;
+
   /* Interrupt handlers need to save extra registers.  */
   if (cfun->machine->interrupt_handler_p
       && mips_interrupt_extra_call_saved_reg_p (regno))
index 2cf1dc6b00a3edba291aa48fe23179728a753ebb..fa74ad298ff412dc703d63cfa6b83af3fc24381a 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-17  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * gcc.target/mips/reg-var-1.c: New test.
+
 2011-04-17  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/winline-5.c: Update testcase.
diff --git a/gcc/testsuite/gcc.target/mips/reg-var-1.c b/gcc/testsuite/gcc.target/mips/reg-var-1.c
new file mode 100644 (file)
index 0000000..d8b8118
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+register int g asm ("$18");
+
+void __attribute__((noinline))
+test (void)
+{
+  g = g + 1;
+}
+
+int
+main (void)
+{
+  g = 2;
+  test ();
+  return g != 3;
+}