public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@redhat.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [Committed] patch fixing LRA crash on s390x
Date: Sun, 15 Nov 2020 12:08:22 -0500	[thread overview]
Message-ID: <0b062f7d-4a76-ed49-6959-bb33dbb13823@redhat.com> (raw)

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

My last patch implementing output reloads in asm goto resulted in LRA 
crash in compiling kernel on s390x.  Jeff Law reported it recently.  The 
culprit was in incorrect emitting reload insns in last empty BB.  The 
emitted insns got null BB which is wrong. Actually in this case we do 
not need to emit such insns as they will removed as dead lately.

The following patch fixes the problem.




[-- Attachment #2: z --]
[-- Type: text/plain, Size: 1395 bytes --]

Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Sun Nov 15 11:22:19 2020 -0500

    Do not put reload insns in the last empty BB.
    
    gcc/
            * lra.c (lra_process_new_insns): Don't put reload insns in the
            last empty BB.

diff --git a/gcc/lra.c b/gcc/lra.c
index 673554d0a4b..b318cfd7456 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -1903,15 +1903,23 @@ lra_process_new_insns (rtx_insn *insn, rtx_insn *before, rtx_insn *after,
 	      {
 		/* We already made the edge no-critical in ira.c::ira */
 		lra_assert (!EDGE_CRITICAL_P (e));
-		rtx_insn *tmp = BB_HEAD (e->dest);
+		rtx_insn *curr, *tmp = BB_HEAD (e->dest);
 		if (LABEL_P (tmp))
 		  tmp = NEXT_INSN (tmp);
 		if (NOTE_INSN_BASIC_BLOCK_P (tmp))
 		  tmp = NEXT_INSN (tmp);
-		start_sequence ();
-		for (rtx_insn *curr = after;
-		     curr != NULL_RTX;
+		for (curr = tmp;
+		     curr != NULL
+		       && (!INSN_P (curr) || BLOCK_FOR_INSN (curr) == e->dest);
 		     curr = NEXT_INSN (curr))
+		  ;
+		/* Do not put reload insns if it is the last BB
+		   without actual insns.  In this case the reload insns
+		   can get null BB after emitting.  */
+		if (curr == NULL)
+		  continue;
+		start_sequence ();
+		for (curr = after; curr != NULL_RTX; curr = NEXT_INSN (curr))
 		  emit_insn (copy_insn (PATTERN (curr)));
 		rtx_insn *copy = get_insns (), *last = get_last_insn ();
 		end_sequence ();

             reply	other threads:[~2020-11-15 17:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 17:08 Vladimir Makarov [this message]
2020-11-22 10:23 ` Jakub Jelinek

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=0b062f7d-4a76-ed49-6959-bb33dbb13823@redhat.com \
    --to=vmakarov@redhat.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).