From patchwork Fri Nov 2 14:45:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 196577 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 51B3A2C00C4 for ; Sat, 3 Nov 2012 01:45:52 +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=1352472352; 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=x36ZDss RdxLgMejUMpFZn6PG2rw=; b=O/HQuHnmaBg4aedyZ632fJrS9sZfy78k8B9KSfx Zt+5Vq3LzqmWNJyCHJ9DvZNmMGqe6aeEkYLmNloNSYrogwc2yj34j5HXVoMWk03J 5y3zV/ytllNTqWDD/uZcEsUTfadLX89uDZidN84fzOImP83Go0ej/VM+mwX+4VjM NnCI= 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:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZKFWvEj4Ar3nGEPwUH9HcRohtBZjV4hZ7e7GpB2oOVDaLkE4b+vulqlYUnR61E hG0kt6JE9JbgqxJ5sXbBCEPZ75cUsxj7eIWzgoFJRWZLONPQvjdClCp0RRbN11ze ZXbzfCfLRF604DwVDQIovi7d/1TBLb1bOWMBIWAlyTO5c=; Received: (qmail 12273 invoked by alias); 2 Nov 2012 14:45:47 -0000 Received: (qmail 12263 invoked by uid 22791); 2 Nov 2012 14:45:46 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Nov 2012 14:45:39 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qA2EjdK9012792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Nov 2012 10:45:39 -0400 Received: from Mair.local (vpn-11-104.rdu.redhat.com [10.11.11.104]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qA2Ejabo011358 for ; Fri, 2 Nov 2012 10:45:38 -0400 Message-ID: <5093DC8F.1040703@redhat.com> Date: Fri, 02 Nov 2012 10:45:35 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR55130 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 The following patch fixes PR55130 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55130 The reason for the crash was in missed processing clobber insn with pseudo changed on its equivalent memory. It resulted in presence of the pseudo and in trying to remove equiv initialization insn the second time. The patch was successfully bootstrapped on x86/x86-64. Committed as rev. 193096. 2012-11-02 Vladimir Makarov PR middle-end/55130 * lra-constraints.c (debug_loc_equivalence_change_p): Rename to loc_equivalence_change_p. (lra_constraints): Check equiv_insn_bitmap for debug insn. Call loc_equivalence_change_p for non-transformed insn. 2012-11-02 Vladimir Makarov PR middle-end/55150 * gcc.target/i386/pr55130.c: New test. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 193065) +++ lra-constraints.c (working copy) @@ -3095,10 +3095,10 @@ contains_reg_p (rtx x, bool hard_reg_p, return false; } -/* Process all regs in debug location *LOC and change them on - equivalent substitution. Return true if any change was done. */ +/* Process all regs in location *LOC and change them on equivalent + substitution. Return true if any change was done. */ static bool -debug_loc_equivalence_change_p (rtx *loc) +loc_equivalence_change_p (rtx *loc) { rtx subst, reg, x = *loc; bool result = false; @@ -3130,11 +3130,11 @@ debug_loc_equivalence_change_p (rtx *loc for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') - result = debug_loc_equivalence_change_p (&XEXP (x, i)) || result; + result = loc_equivalence_change_p (&XEXP (x, i)) || result; else if (fmt[i] == 'E') for (j = XVECLEN (x, i) - 1; j >= 0; j--) result - = debug_loc_equivalence_change_p (&XVECEXP (x, i, j)) || result; + = loc_equivalence_change_p (&XVECEXP (x, i, j)) || result; } return result; } @@ -3322,7 +3322,6 @@ lra_constraints (bool first_p) substituted by their equivalences. */ EXECUTE_IF_SET_IN_BITMAP (&equiv_insn_bitmap, 0, uid, bi) lra_push_insn_by_uid (uid); - bitmap_clear (&equiv_insn_bitmap); lra_eliminate (false); min_len = lra_insn_stack_length (); new_insns_num = 0; @@ -3353,7 +3352,8 @@ lra_constraints (bool first_p) /* We need to check equivalence in debug insn and change pseudo to the equivalent value if necessary. */ curr_id = lra_get_insn_recog_data (curr_insn); - if (debug_loc_equivalence_change_p (curr_id->operand_loc[0])) + if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn)) + && loc_equivalence_change_p (curr_id->operand_loc[0])) { lra_update_insn_regno_info (curr_insn); changed_p = true; @@ -3417,8 +3417,18 @@ lra_constraints (bool first_p) init_curr_operand_mode (); if (curr_insn_transform ()) changed_p = true; + /* Check non-transformed insns too for equiv change as USE + or CLOBBER don't need reloads but can contain pseudos + being changed on their equivalences. */ + else if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn)) + && loc_equivalence_change_p (&PATTERN (curr_insn))) + { + lra_update_insn_regno_info (curr_insn); + changed_p = true; + } } } + bitmap_clear (&equiv_insn_bitmap); /* If we used a new hard regno, changed_p should be true because the hard reg is assigned to a new pseudo. */ #ifdef ENABLE_CHECKING Index: testsuite/gcc.target/i386/pr55130.c =================================================================== --- testsuite/gcc.target/i386/pr55130.c (revision 0) +++ testsuite/gcc.target/i386/pr55130.c (working copy) @@ -0,0 +1,15 @@ +/* PR middle-end/55130 */ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "-O1 -mregparm=3 -mpreferred-stack-boundary=2" } */ + +extern void bar(long long); + +int foo(long long a, char b, long long c, long long d) +{ + if (c == 0) + c = d; + + bar(b + c); + + return a == d; +}