From patchwork Wed Jan 4 14:07:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Shawcroft X-Patchwork-Id: 134254 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 C064B1007D6 for ; Thu, 5 Jan 2012 01:08:18 +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=1326290900; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=VQpXaK7 fRjUVmWuqY11HoUsyfjA=; b=qRs2pvo3+aapNFtNnSJ2xODSS300KzvxFb+ZuoW Cd7I9MmrGyFHRzCnXgwJ3OX6R07Fojx1VCLhop3zjd+1P/i8ezWprw2cHWxJIAcX 7kXhggtP+k1EtW12ebiPs7yjYxyVku1LHMd7/0Kh7wHQKFRR0CrPbnWIkT7s0upJ zgvw= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:X-MC-Unique:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dqzvtivV1K6S8dZsaK2G2pgsAkpwm+sKE+Ip1bRTMaf0mB9eMlFXVN69WtFEuj yqDiiZhvVgRp8jglypSPfDGCFR28M9KhUKL0admbIv94TEccUlCim1CYm8aQvBif IXw/yiq78iT9OUSYDeFqB3yj4onibR0Ije+A0XNVBwwrs=; Received: (qmail 15533 invoked by alias); 4 Jan 2012 14:08:14 -0000 Received: (qmail 15524 invoked by uid 22791); 4 Jan 2012 14:08:12 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jan 2012 14:07:59 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 04 Jan 2012 14:07:54 +0000 Received: from [10.1.72.172] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 4 Jan 2012 14:07:51 +0000 Message-ID: <4F045D38.7060204@arm.com> Date: Wed, 04 Jan 2012 14:07:52 +0000 From: Marcus Shawcroft User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add missed adjustment to label_nuses in reload. X-MC-Unique: 112010414075401601 X-IsSubscribed: yes 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 Reload (find_reloads) has code that can replace a register with a label_ref when presented with RTL of the form: (set (reg) (reg) (notes (rtx_equal (label_ref))) Label references are initially counted in jump.c:mark_all_labels() and friends. This code traverses the RTL and counts each observed label_ref. The code inserts REG_LABEL_OPERAND or REG_LABEL_TARGET as appropriate. Notes are not traversed therefore the (rtx_equal (label_ref)) shown above is not treated as a reference. Instruction deletion, in cfgrtl.c:delete_insn() does not re-traverse the RTL, The code traverses only the notes looking for REG_LABEL_OPERAND and REG_TARGET_OPERAND notes in order to count down the label_nuses field. The code in reload.c:find_reloads() converts a register to a label_ref and inserts the associated REG_LABEL_OPERAND but does not adjust label_nuses, this may result in the inappropriate deletion of a live label. This issue was discovered during the development of the ARM aarch64 gcc backend and results in an ICE due to deletion of a live jump table. The issue has not been re-created on another target. The proposed patch has been regressed on x86 (and aarch64). Proposed ChangeLog entry below, patch attached: 2012-01-04 Marcus Shawcroft * reload.c (find_reloads): Adjust LABEL_NUSES on REG_LABEL_OPERAND insertion. /Marcus diff --git a/gcc/reload.c b/gcc/reload.c index 53dcd2d..206fb36 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -4212,7 +4212,12 @@ find_reloads (rtx insn, int replace, int ind_levels, int live_known, && (!JUMP_P (insn) || !label_is_jump_target_p (XEXP (substitution, 0), insn))) - add_reg_note (insn, REG_LABEL_OPERAND, XEXP (substitution, 0)); + { + add_reg_note (insn, REG_LABEL_OPERAND, XEXP (substitution, 0)); + if (LABEL_P (XEXP (substitution, 0))) + ++ LABEL_NUSES(XEXP (substitution, 0)); + } + } else retval |= (substed_operand[i] != *recog_data.operand_loc[i]);