public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, MIPS] relax-pic-calls and complex return types
@ 2010-04-26  1:24 Jim Wilson
  2010-05-08  8:52 ` Richard Sandiford
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Wilson @ 2010-04-26  1:24 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]

This is for the problem I reported in PR43764.  Using -mabicalls with
the mipsisa32r2-sde-elf toolchain on a function returning complex
results in an ICE.  The -mrelax-pic-calls code is trying to modify
patterns that contain a CALL rtx, but it only modifies the first one,
and complex return values have two CALL rtx because the result is return
in two discontiguous registers.

This patch is a simple solution to that problem.
mips_call_expr_from_insn was modified to have a parameter passed by
address that we can store the second CALL rtx in.  Then the caller
modifies the second CALL rtx same as the first one if it exists.

This was tested using the mipsisa32r2-sde-elf toolchain on the
simulator, with -mabicalls and -G0.  With the patch, there are 50 fewer
ICEs in the gcc testsuite, and 10 fewer ICEs in the g++ testsuite.  The
toolchain went from 75 ICEs total to 15.  There were no new regressions.

OK?

Jim


[-- Attachment #2: relax-pic-complex.patch --]
[-- Type: text/x-patch, Size: 2022 bytes --]

2010-04-24  James E. Wilson  <wilson@codesourcery.com>

	PR target/43764
	* mips.c (mips_call_expr_from_insn): New arg second_call.  Set it.
	(mips_annotate_pic_calls): Pass new arg to mips_call_expr_from_insn.
	Use it.

Index: mips.c
===================================================================
--- mips.c	(revision 158495)
+++ mips.c	(working copy)
@@ -14007,23 +14025,35 @@ r10k_insert_cache_barriers (void)
 }
 \f
 /* If INSN is a call, return the underlying CALL expr.  Return NULL_RTX
-   otherwise.  */
+   otherwise.  If INSN has two call rtx, then store the second one in
+   SECOND_CALL.  */
 
 static rtx
-mips_call_expr_from_insn (rtx insn)
+mips_call_expr_from_insn (rtx insn, rtx *second_call)
 {
   rtx x;
+  rtx x2;
 
   if (!CALL_P (insn))
     return NULL_RTX;
 
   x = PATTERN (insn);
   if (GET_CODE (x) == PARALLEL)
-    x = XVECEXP (x, 0, 0);
+    {
+      /* Calls returning complex values have two CALL rtx.  Look for the second
+	 one here, and return it via the SECOND_CALL arg.  */
+      x2 = XVECEXP (x, 0, 1);
+      if (GET_CODE (x2) == SET)
+	x2 = XEXP (x2, 1);
+      if (GET_CODE (x2) == CALL)
+	*second_call = x2;
+
+      x = XVECEXP (x, 0, 0);
+    }
   if (GET_CODE (x) == SET)
     x = XEXP (x, 1);
-
   gcc_assert (GET_CODE (x) == CALL);
+
   return x;
 }
 
@@ -14155,9 +14185,10 @@ mips_annotate_pic_calls (void)
   FOR_EACH_BB (bb)
     FOR_BB_INSNS (bb, insn)
     {
-      rtx call, reg, symbol;
+      rtx call, reg, symbol, second_call;
 
-      call = mips_call_expr_from_insn (insn);
+      second_call = 0;
+      call = mips_call_expr_from_insn (insn, &second_call);
       if (!call)
 	continue;
       gcc_assert (MEM_P (XEXP (call, 0)));
@@ -14167,7 +14198,11 @@ mips_annotate_pic_calls (void)
 
       symbol = mips_find_pic_call_symbol (insn, reg);
       if (symbol)
-	mips_annotate_pic_call_expr (call, symbol);
+	{
+	  mips_annotate_pic_call_expr (call, symbol);
+	  if (second_call)
+	    mips_annotate_pic_call_expr (second_call, symbol);
+	}
     }
 }
 \f

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

* Re: [PATCH, MIPS] relax-pic-calls and complex return types
  2010-04-26  1:24 [PATCH, MIPS] relax-pic-calls and complex return types Jim Wilson
@ 2010-05-08  8:52 ` Richard Sandiford
  2010-05-20  6:46   ` Jim Wilson
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2010-05-08  8:52 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc-patches

Jim Wilson <wilson@codesourcery.com> writes:
> 	PR target/43764
> 	* mips.c (mips_call_expr_from_insn): New arg second_call.  Set it.
> 	(mips_annotate_pic_calls): Pass new arg to mips_call_expr_from_insn.
> 	Use it.

OK for trunk, thanks.  I think it should go on 4.5 too, if a release
manager agrees.

Richard

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

* Re: [PATCH, MIPS] relax-pic-calls and complex return types
  2010-05-08  8:52 ` Richard Sandiford
@ 2010-05-20  6:46   ` Jim Wilson
  2010-05-20 22:21     ` Richard Sandiford
  0 siblings, 1 reply; 4+ messages in thread
From: Jim Wilson @ 2010-05-20  6:46 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

On Sat, 2010-05-08 at 09:51 +0100, Richard Sandiford wrote:
> Jim Wilson <wilson@codesourcery.com> writes:
> > 	PR target/43764
> > 	* mips.c (mips_call_expr_from_insn): New arg second_call.  Set it.
> > 	(mips_annotate_pic_calls): Pass new arg to mips_call_expr_from_insn.
> > 	Use it.
> OK for trunk, thanks.  I think it should go on 4.5 too, if a release
> manager agrees.

I checked it into trunk.  Do I really need a separate approval for 4.5?
The most recent status report (2010-04-14) says it is open for
regression fixes.  The second most recent status report (2010-03-31),
before the release, did say it was frozen and all patches required
release manager approval.

Jim


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

* Re: [PATCH, MIPS] relax-pic-calls and complex return types
  2010-05-20  6:46   ` Jim Wilson
@ 2010-05-20 22:21     ` Richard Sandiford
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Sandiford @ 2010-05-20 22:21 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc-patches

Jim Wilson <wilson@codesourcery.com> writes:
> On Sat, 2010-05-08 at 09:51 +0100, Richard Sandiford wrote:
>> Jim Wilson <wilson@codesourcery.com> writes:
>> > 	PR target/43764
>> > 	* mips.c (mips_call_expr_from_insn): New arg second_call.  Set it.
>> > 	(mips_annotate_pic_calls): Pass new arg to mips_call_expr_from_insn.
>> > 	Use it.
>> OK for trunk, thanks.  I think it should go on 4.5 too, if a release
>> manager agrees.
>
> I checked it into trunk.  Do I really need a separate approval for 4.5?
> The most recent status report (2010-04-14) says it is open for
> regression fixes.  The second most recent status report (2010-03-31),
> before the release, did say it was frozen and all patches required
> release manager approval.

Ah, you're probably right.  In that case, please go ahead.

Richard

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

end of thread, other threads:[~2010-05-20 22:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26  1:24 [PATCH, MIPS] relax-pic-calls and complex return types Jim Wilson
2010-05-08  8:52 ` Richard Sandiford
2010-05-20  6:46   ` Jim Wilson
2010-05-20 22:21     ` 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).