public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix handling of global registers in MIPS prologues
@ 2011-04-17 18:40 Richard Sandiford
  2011-04-17 21:31 ` Mikael Pettersson
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2011-04-17 18:40 UTC (permalink / raw)
  To: gcc-patches

PR 45074 showed up a rather embarrassing oversight in the MIPS backend:
global registers were still being treated as call-saved.

Fixed with the attached patch.  Tested on mips64-linux-gnu and applied.

Richard


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.

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2011-04-16 09:02:10.000000000 +0100
+++ gcc/config/mips/mips.c	2011-04-17 11:14:53.000000000 +0100
@@ -9097,6 +9097,11 @@ mips_interrupt_extra_call_saved_reg_p (u
 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: gcc/testsuite/gcc.target/mips/reg-var-1.c
===================================================================
--- /dev/null	2011-04-17 10:56:28.045573347 +0100
+++ gcc/testsuite/gcc.target/mips/reg-var-1.c	2011-04-17 11:22:39.000000000 +0100
@@ -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;
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] Fix handling of global registers in MIPS prologues
  2011-04-17 18:40 [committed] Fix handling of global registers in MIPS prologues Richard Sandiford
@ 2011-04-17 21:31 ` Mikael Pettersson
  2011-05-29 20:41   ` Richard Sandiford
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Pettersson @ 2011-04-17 21:31 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

Richard Sandiford writes:
 > PR 45074 showed up a rather embarrassing oversight in the MIPS backend:
 > global registers were still being treated as call-saved.
 > 
 > Fixed with the attached patch.  Tested on mips64-linux-gnu and applied.
 > 
 > Richard
 > 
 > 
 > gcc/
 > 	* config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global
 > 	registers.

This bug is also PR target/43700, a regression since gcc-4.4.
Do you want to backport the fix, or perhaps just mark PR43700
as fixed in 4.7.0?

/Mikael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] Fix handling of global registers in MIPS prologues
  2011-04-17 21:31 ` Mikael Pettersson
@ 2011-05-29 20:41   ` Richard Sandiford
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2011-05-29 20:41 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: gcc-patches

Mikael Pettersson <mikpe@it.uu.se> writes:
> Richard Sandiford writes:
>  > PR 45074 showed up a rather embarrassing oversight in the MIPS backend:
>  > global registers were still being treated as call-saved.
>  > 
>  > Fixed with the attached patch.  Tested on mips64-linux-gnu and applied.
>  > 
>  > Richard
>  > 
>  > 
>  > gcc/
>  > 	* config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global
>  > 	registers.
>
> This bug is also PR target/43700, a regression since gcc-4.4.
> Do you want to backport the fix, or perhaps just mark PR43700
> as fixed in 4.7.0?

I've now backported it to 4.4, 4.5 and 4.6.  Sorry for the delay.

Richard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-29 18:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-17 18:40 [committed] Fix handling of global registers in MIPS prologues Richard Sandiford
2011-04-17 21:31 ` Mikael Pettersson
2011-05-29 20:41   ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).