From patchwork Tue Feb 5 09:41:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 218204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id AEC132C02E9 for ; Tue, 5 Feb 2013 20:42:20 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1360662142; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=wZrYrt8WTlB1D7hdoonBrfyjDQ8=; b=HHNvBNntc4NTYY3Z+RZx7xSTRPfRcWvcR01OJQXQmd9U9kXHCLGIi+n+rbiOhq bjXZaaFRvSUV4ZlEyigqqzOap3ImVqCHDowv02QrEEaRWfGLhYKy/CspiX5vZ6TL bAUnKN9ldqgyWAVPHKsaNyfPZhAYTgYrE1MVFGyWAxGqA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Y5o8dgbAINZYn4t+I1BAo3PA7TFUlMjBDC1TIc2c514qhhJiGbXAfV0DjEjmJ6 be9y8Z8o7F/OVF5vH7x+5VhF2+d/08mULgLwNdQpKcGJ+0Z8aRUDcDTvKv7inH+2 sI5x+OrFcpHZxRre3GVg2UwGX2FBB8YJDS21lnyhkQvwM=; Received: (qmail 25555 invoked by alias); 5 Feb 2013 09:42:13 -0000 Received: (qmail 25546 invoked by uid 22791); 5 Feb 2013 09:42:12 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Feb 2013 09:42:02 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1U2f2O-000573-HK from Tom_deVries@mentor.com ; Tue, 05 Feb 2013 01:42:00 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 5 Feb 2013 01:42:00 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 5 Feb 2013 09:41:57 +0000 Message-ID: <5110D3DF.2050904@mentor.com> Date: Tue, 5 Feb 2013 10:41:51 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Eric Botcazou CC: , Mikael Pettersson Subject: Re: [PATCH] Fix PR56131 - gcc.dg/pr56035.c ICEs gcc on sparc-linux References: <510FF01D.5040309@mentor.com> <1551618.pBYOJKzDYv@polaris> In-Reply-To: <1551618.pBYOJKzDYv@polaris> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Eric, thanks for the review. On 05/02/13 10:02, Eric Botcazou wrote: >> The problem is that in delete_insn, while deleting an undeletable label (in >> other words, transforming a label into a INSN_NOTE_DELETED_LABEL): >> - we try to find the bb of a NOTE_INSN_BASIC_BLOCK following the label using >> BLOCK_FOR_INSN (which is NULL) instead of NOTE_BASIC_BLOCK (which is not >> NULL), and >> - we don't handle the case that we find a NULL pointer for that bb >> gracefully. > > Can the NOTE_BASIC_BLOCK of a NOTE_INSN_BASIC_BLOCK really be NULL? > I don't know, I was just trying to do defensive programming. >> This comment in insn-notes.def tells us that the bb info could be in either >> of the two: >> ... >> /* Record the struct for the following basic block. Uses >> NOTE_BASIC_BLOCK. FIXME: Redundant with the basic block pointer >> now included in every insn. */ >> INSN_NOTE (BASIC_BLOCK) >> ... >> >> The patch fixes the problems by: >> - using NOTE_BASIC_BLOCK to find the bb of NOTE_INSN_BASIC_BLOCK, and >> - explicitly handling the cases that the bb of either the label or the note >> is NULL. > > I don't think that we need to handle the very last case. > OK. >> 2013-02-04 Tom de Vries >> >> PR rtl-optimization/56131 >> * cfgrtl.c (delete_insn): Use NOTE_BASIC_BLOCK instead of BLOCK_FOR_INSN >> to get the bb of a NOTE_INSN_BASIC_BLOCK. Handle the case that the bb >> of the label is NULL. Add comment. > > OK on principle, but remove the handling of the NULL NOTE_BASIC_BLOCK and keep > everything in a single condition. > I've adopted the patch according to your comments, rebuild sparc-linux cc1 and tested that the ICE does not occur. I'll bootstrap and retest on x86_64 and check in attached patch. Thanks, - Tom Index: gcc/cfgrtl.c =================================================================== --- gcc/cfgrtl.c (revision 195747) +++ gcc/cfgrtl.c (working copy) @@ -135,7 +135,7 @@ delete_insn (rtx insn) if (! can_delete_label_p (insn)) { const char *name = LABEL_NAME (insn); - basic_block bb = BLOCK_FOR_INSN (insn); + basic_block bb, label_bb = BLOCK_FOR_INSN (insn); rtx bb_note = NEXT_INSN (insn); really_delete = false; @@ -143,10 +143,16 @@ delete_insn (rtx insn) NOTE_KIND (insn) = NOTE_INSN_DELETED_LABEL; NOTE_DELETED_LABEL_NAME (insn) = name; - if (bb_note != NULL_RTX && NOTE_INSN_BASIC_BLOCK_P (bb_note) - && BLOCK_FOR_INSN (bb_note) == bb) + /* If the note following the label starts a basic block, and the + label is a member of the same basic block, interchange the two. + If the label is not marked with a bb, assume it's the same bb. */ + if (bb_note != NULL_RTX + && NOTE_INSN_BASIC_BLOCK_P (bb_note) + && (label_bb == NOTE_BASIC_BLOCK (bb_note) + || label_bb == NULL)) { reorder_insns_nobb (insn, insn, bb_note); + bb = NOTE_BASIC_BLOCK (bb_note); BB_HEAD (bb) = bb_note; if (BB_END (bb) == bb_note) BB_END (bb) = insn;