From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5264 invoked by alias); 7 Dec 2012 11:59:30 -0000 Received: (qmail 5191 invoked by uid 48); 7 Dec 2012 11:59:15 -0000 From: "steven at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: wrong-debug X-Bugzilla-Severity: normal X-Bugzilla-Who: steven at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00687.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43631 --- Comment #14 from Steven Bosscher 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; }