From patchwork Fri Feb 26 16:15:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 589171 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9019E14029E for ; Sat, 27 Feb 2016 03:15:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Q0Zy9Kiv; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=XOYwOZzlMQSniBY+mZWJHbApuOI9sir4AMiffq+RHm/lN2snMs 96StO3cMEZHVkPM/Ql+f2HGKIFZXDsQB8HZ7i/t7uDsF4jeonkehjlrkOWbyWj+F ETPGndAEwhIpEe+hZ7SMXTxcjMRE80woMPPB+apaePcbFk+GVUlBBoH/Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=OKt7/Mh5McbtM/wf6NdsamYyMj8=; b=Q0Zy9KivJrWRarE6fouB uVROCrW7x7g+5zYlrXQJISns3+/HZC11hzHJ6f90/LLJQMnVZTn+IobxPzh0kkpH BnlCilD9s/i8647OQoPn6cYFTxOHs9E6c8QqP2WDiuaXAqObHBG95hCY7iCAb/uw JVHziGataqpQiNGlSmazEGc= Received: (qmail 5860 invoked by alias); 26 Feb 2016 16:15:49 -0000 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 Received: (qmail 5838 invoked by uid 89); 26 Feb 2016 16:15:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:grp_uns, lucky, sk:access_ X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 26 Feb 2016 16:15:48 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9A306ACDA for ; Fri, 26 Feb 2016 16:15:43 +0000 (UTC) Date: Fri, 26 Feb 2016 17:15:43 +0100 From: Martin Jambor To: GCC Patches Cc: Richard Biener Subject: [PR 69920] Prevent SRA from leaving a removed SSA_NAME in IL Message-ID: <20160226161543.GM3094@virgil.suse.cz> Mail-Followup-To: GCC Patches , Richard Biener MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, my fix for PR 69666 has caused quite a few regressions accross the borad where SRA removed a SSA_NAME which however still was in the IL (and usually stumbled upon it itself straight away). The removal path should not be executed when there is an SSA_NAME on the LHS, the code clearly is not ready for it. Before my patch, we got always lucky because the statement was simply modified elsewhere when the LHS was an SSA_NAME. However, even that was not 10% guaranteed because of the !access_has_replacements_p (racc) part of the changed condition. The patch below fixes the ICEs simply by guarding the removal code to only work when the LHS is not an SSA_NAME. This means that the safe path below it is going to execute. I have bootstrapped and tested the patch on x86_64-linux. I'd like to commit it to trunk as soon as it gets approved and then I'd like to commit it to gcc-5 branch together with the PR 69666 fix a few days afterwards. OK? Thanks, Martin 2016-02-26 Martin Jambor PR middle-end/69920 * tree-sra.c (sra_modify_assign): Do not remove loads of uninitialized aggregates to SSA_NAMEs. testsuite/ * gcc.dg/torture/pr69932.c: New test. * gcc.dg/torture/pr69936.c: Likewise. --- gcc/testsuite/gcc.dg/torture/pr69932.c | 10 ++++++++++ gcc/testsuite/gcc.dg/torture/pr69936.c | 24 ++++++++++++++++++++++++ gcc/tree-sra.c | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr69932.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr69936.c diff --git a/gcc/testsuite/gcc.dg/torture/pr69932.c b/gcc/testsuite/gcc.dg/torture/pr69932.c new file mode 100644 index 0000000..4b82130 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr69932.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int a; +void fn1() { + int b = 4; + short c[4]; + c[b] = c[a]; + if (c[2]) {} + +} diff --git a/gcc/testsuite/gcc.dg/torture/pr69936.c b/gcc/testsuite/gcc.dg/torture/pr69936.c new file mode 100644 index 0000000..3023bbb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr69936.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +int a; +char b; +void fn1(int p1) {} + +int fn2() { return 5; } + +void fn3() { + if (fn2()) + ; + else { + char c[5]; + c[0] = 5; + lbl_608: + fn1(c[9]); + int d = c[9]; + c[2] | a; + d = c[b]; + } + goto lbl_608; +} + +int main() { return 0; } diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 663ded2..366f413 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -3504,7 +3504,8 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) else { if (access_has_children_p (racc) - && !racc->grp_unscalarized_data) + && !racc->grp_unscalarized_data + && TREE_CODE (lhs) != SSA_NAME) { if (dump_file) {