public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steven at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/43631] var-tracking inserts notes with non-NULL BLOCK_FOR_INSN in between basic blocks
Date: Fri, 07 Dec 2012 11:59:00 -0000	[thread overview]
Message-ID: <bug-43631-4-DiGJx6qPOk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-43631-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43631

--- Comment #14 from Steven Bosscher <steven at gcc dot gnu.org> 2012-12-07 11:59:15 UTC ---
(In reply to comment #13)
> Please hold on with that, seems BB_END is BARRIER, which is wrong.
> Starting with distilling a testcase...

Perhaps Alex' is right that the real problem is in how BLOCK_FOR_INSN
is handled in add_insn_after and add_insn_before.  Jakub, does the
following make sense to you?

Index: emit-rtl.c
===================================================================
--- emit-rtl.c  (revision 194229)
+++ emit-rtl.c  (working copy)
@@ -3845,19 +3845,25 @@ add_insn_after (rtx insn, rtx after, bas
       gcc_assert (stack);
     }

-  if (!BARRIER_P (after)
-      && !BARRIER_P (insn)
-      && (bb = BLOCK_FOR_INSN (after)))
+  /* If the new insn is a barrier, bb should be NULL because a barrier
+     is never inside a basic block.  Also avoid emitting double barriers.  */
+  if (BARRIER_P (insn))
+    gcc_checking_assert (bb == NULL && !BARRIER_P (after));
+  /* Otherwise, try to deduce a basic block from AFTER.  */
+  else if (!bb
+          && !BARRIER_P (after)
+          && BLOCK_FOR_INSN (after) != NULL
+          && after != BB_END (BLOCK_FOR_INSN (after)))
+    bb = BLOCK_FOR_INSN (after);
+
+  if (bb)
     {
       set_block_for_insn (insn, bb);
       if (INSN_P (insn))
        df_insn_rescan (insn);
-      /* Should not happen as first in the BB is always
-        either NOTE or LABEL.  */
-      if (BB_END (bb) == after
-         /* Avoid clobbering of structure when creating new BB.  */
-         && !BARRIER_P (insn)
-         && !NOTE_INSN_BASIC_BLOCK_P (insn))
+      /* Move BB_END from AFTER to INSN unless INSN is a note (a note cannot
+        be the end a basic block).  */
+      if (BB_END (bb) == after && !NOTE_P (insn))
        BB_END (bb) = insn;
     }


  parent reply	other threads:[~2012-12-07 11:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-43631-4@http.gcc.gnu.org/bugzilla/>
2010-12-17 21:43 ` steven at gcc dot gnu.org
2011-03-28 17:45 ` steven at gcc dot gnu.org
2012-03-17  0:38 ` steven at gcc dot gnu.org
2012-11-13 10:50 ` jakub at gcc dot gnu.org
2012-11-13 23:39 ` steven at gcc dot gnu.org
2012-12-06 14:38 ` jakub at gcc dot gnu.org
2012-12-06 14:47 ` jakub at gcc dot gnu.org
2012-12-07 10:12 ` izamyatin at gmail dot com
2012-12-07 10:17 ` stevenb.gcc at gmail dot com
2012-12-07 10:22 ` jakub at gcc dot gnu.org
2012-12-07 10:24 ` izamyatin at gmail dot com
2012-12-07 10:30 ` jakub at gcc dot gnu.org
2012-12-07 11:59 ` steven at gcc dot gnu.org [this message]
2012-12-07 12:12 ` jakub at gcc dot gnu.org
2012-12-07 12:47 ` ubizjak at gmail dot com
2012-12-10  8:03 ` izamyatin at gmail dot com
2012-12-11 10:42 ` jakub at gcc dot gnu.org
2012-12-11 10:49 ` jakub at gcc dot gnu.org
2012-12-12  9:56 ` jakub at gcc dot gnu.org
2012-12-12 10:01 ` jakub at gcc dot gnu.org
2012-12-17  8:48 ` ubizjak at gmail dot com
2013-04-03 20:30 ` steven at gcc dot gnu.org
2013-04-06 12:39 ` steven at gcc dot gnu.org
2013-04-16 20:12 ` steven at gcc dot gnu.org
2015-01-20 15:33 ` ubizjak at gmail dot com
2015-02-01 21:56 ` jakub at gcc dot gnu.org
2010-04-02 15:25 [Bug middle-end/43631] New: " steven at gcc dot gnu dot org
2010-07-17 22:56 ` [Bug middle-end/43631] " steven at gcc dot gnu dot org

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=bug-43631-4-DiGJx6qPOk@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).