Fix MIPS NewABI fallout from recent tree-nested.c fix

Richard Sandiford rdsandiford@googlemail.com
Wed Jun 4 18:31:00 GMT 2008


"Richard Guenther" <richard.guenther@gmail.com> writes:
> On Tue, Jun 3, 2008 at 8:22 PM, Richard Sandiford
> <rdsandiford@googlemail.com> wrote:
>> "Richard Guenther" <richard.guenther@gmail.com> writes:
>>> On Mon, Jun 2, 2008 at 11:17 PM, Richard Sandiford
>>> <rdsandiford@googlemail.com> wrote:
>>>> Eric's recent tree-nested.c patch allows us to inline gcc.dg/nest.c:foo
>>>> into main.  This creates a function in which the only use of the $gp
>>>> register is an implicit one in FUNCTION_PROFILER, and a bug in the
>>>> MIPS port meant that we'd delete the initialisation as dead.
>>>>
>>>> Fixed by extending the !TARGET_EXPLICIT_RELOCS case to include
>>>> crtl->profile as well, and making sure that it is used even
>>>> for LOADGP_ABSOLUTE (for which !TARGET_EXPLICIT_RELOCS is known
>>>> to be false).
>>>>
>>>> Tested on mips64el-linux-gnu and applied.
>>>
>>> Erics patch also went on the 4.3 branch.  If you are comfortable with
>>> your change can you also put it there to not regress on the branch?
>>
>> OK, will do.  Thanks for the heads-up.
>>
>> Can I put it in before 4.3.1, or should I wait until after the release?
>
> You can put it in now.

Thanks.  Here's what I applied after testing on mips64el-linux-gnu.
I'll do the 4.2 and 4.1 branches next.

Richard


gcc/
	* config/mips/mips.c (mips_emit_loadgp): Return early if
	there is nothing do to, otherwise emit a blockage if
	!TARGET_EXPLICIT_RELOCS || current_function_profile.
	* config/mips/mips.md (loadgp_blockage): Use SI rather than DI.

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2008-06-03 20:11:04.000000000 +0100
+++ gcc/config/mips/mips.c	2008-06-03 21:26:57.000000000 +0100
@@ -8339,8 +8339,6 @@ mips_emit_loadgp (void)
       emit_insn (Pmode == SImode
 		 ? gen_loadgp_newabi_si (pic_reg, offset, incoming_address)
 		 : gen_loadgp_newabi_di (pic_reg, offset, incoming_address));
-      if (!TARGET_EXPLICIT_RELOCS)
-	emit_insn (gen_loadgp_blockage ());
       break;
 
     case LOADGP_RTP:
@@ -8349,13 +8347,16 @@ mips_emit_loadgp (void)
       emit_insn (Pmode == SImode
 		 ? gen_loadgp_rtp_si (pic_reg, base, index)
 		 : gen_loadgp_rtp_di (pic_reg, base, index));
-      if (!TARGET_EXPLICIT_RELOCS)
-	emit_insn (gen_loadgp_blockage ());
       break;
 
     default:
-      break;
+      return;
     }
+  /* Emit a blockage if there are implicit uses of the GP register.
+     This includes profiled functions, because FUNCTION_PROFILE uses
+     a jal macro.  */
+  if (!TARGET_EXPLICIT_RELOCS || current_function_profile)
+    emit_insn (gen_loadgp_blockage ());
 }
 
 /* Expand the "prologue" pattern.  */
Index: gcc/config/mips/mips.md
===================================================================
--- gcc/config/mips/mips.md	2008-06-03 20:11:04.000000000 +0100
+++ gcc/config/mips/mips.md	2008-06-03 20:11:23.000000000 +0100
@@ -4304,12 +4304,11 @@ (define_insn_and_split "loadgp_absolute_
 }
   [(set_attr "length" "8")])
 
-;; The use of gp is hidden when not using explicit relocations.
 ;; This blockage instruction prevents the gp load from being
 ;; scheduled after an implicit use of gp.  It also prevents
 ;; the load from being deleted as dead.
 (define_insn "loadgp_blockage"
-  [(unspec_volatile [(reg:DI 28)] UNSPEC_BLOCKAGE)]
+  [(unspec_volatile [(reg:SI 28)] UNSPEC_BLOCKAGE)]
   ""
   ""
   [(set_attr "type"	"unknown")



More information about the Gcc-patches mailing list