public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rdsandiford@googlemail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: PR 48826: NOTE_INSN_CALL_ARG_LOCATION vs. define_split
Date: Mon, 23 May 2011 20:16:00 -0000	[thread overview]
Message-ID: <87aaeds3jh.fsf@firetop.home> (raw)
In-Reply-To: <201105230913.33760.ebotcazou@adacore.com> (Eric Botcazou's	message of "Mon, 23 May 2011 09:13:33 +0200")

Eric Botcazou <ebotcazou@adacore.com> writes:
>> 	PR rtl-optimization/48826
>> 	* emit-rtl.c (try_split): When splitting a call that is followed
>> 	by a NOTE_INSN_CALL_ARG_LOCATION, move the note after the new call.
>
> OK if you move up the comment and merge it in the comment of the
> block.  And it would be nice to add the missing blurb about the
> SIBLING_CALL_P flag.  TIA.

Doh, good catch.

In the end, it felt a bit awkward stringing together three essentially
separate bits of info into one comment, so I instead generalised the
block comment and added specific comments above each section.

It sounded like you were more concerned with having the comments staying
in sync than the actual specifics, so I went ahead and installed the
patch below.  Please let me know if you'd prefer something different
though.

Thanks,
Richard


gcc/
	PR rtl-optimization/48826
	* emit-rtl.c (try_split): When splitting a call that is followed
	by a NOTE_INSN_CALL_ARG_LOCATION, move the note after the new call.

Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	2011-05-22 22:19:08.000000000 +0100
+++ gcc/emit-rtl.c	2011-05-23 18:48:23.000000000 +0100
@@ -3470,17 +3470,40 @@ try_split (rtx pat, rtx trial, int last)
     }
 
   /* If we are splitting a CALL_INSN, look for the CALL_INSN
-     in SEQ and copy our CALL_INSN_FUNCTION_USAGE to it.  */
+     in SEQ and copy any additional information across.  */
   if (CALL_P (trial))
     {
       for (insn = insn_last; insn ; insn = PREV_INSN (insn))
 	if (CALL_P (insn))
 	  {
-	    rtx *p = &CALL_INSN_FUNCTION_USAGE (insn);
+	    rtx next, *p;
+
+	    /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the
+	       target may have explicitly specified.  */
+	    p = &CALL_INSN_FUNCTION_USAGE (insn);
 	    while (*p)
 	      p = &XEXP (*p, 1);
 	    *p = CALL_INSN_FUNCTION_USAGE (trial);
+
+	    /* If the old call was a sibling call, the new one must
+	       be too.  */
 	    SIBLING_CALL_P (insn) = SIBLING_CALL_P (trial);
+
+	    /* If the new call is the last instruction in the sequence,
+	       it will effectively replace the old call in-situ.  Otherwise
+	       we must move any following NOTE_INSN_CALL_ARG_LOCATION note
+	       so that it comes immediately after the new call.  */
+	    if (NEXT_INSN (insn))
+	      {
+		next = NEXT_INSN (trial);
+		if (next
+		    && NOTE_P (next)
+		    && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION)
+		  {
+		    remove_insn (next);
+		    add_insn_after (next, insn, NULL);
+		  }
+	      }
 	  }
     }
 

  reply	other threads:[~2011-05-23 17:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23  2:07 Richard Sandiford
2011-05-23  9:30 ` Eric Botcazou
2011-05-23 20:16   ` Richard Sandiford [this message]
2011-05-23 22:46     ` Eric Botcazou
2011-05-29  1:07     ` Richard Sandiford
2011-05-29 14:31       ` Eric Botcazou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87aaeds3jh.fsf@firetop.home \
    --to=rdsandiford@googlemail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).