From patchwork Sun Dec 11 19:35:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 704866 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 3tcGRg6y1Gz9t0Z for ; Mon, 12 Dec 2016 06:36:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="skUizWrx"; 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=ELLf3 ot3FxjA2y0aNGeMw8VilFRa4Fx+ht+pn00XNGA8Qzs1xzhtcWw8i44SxEYP5JE6t mvSKah9XJQ/OwbfWGtIam8XnguUJOp++KMZTsG5fjOZPafxIQeA+xJYNReSgFr7w qiroByop5g2Vp6lzjptyxBsJBuctryI1XctYg0= 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=Mq1YUBFcHy9 JlF/9tSHwk2F/eFE=; b=skUizWrxQG7gfuSgHg3voj2pCGAISKx1eNMi7Sf3498 9QOK4CcdVc2Bmblven4NlD56T2d7tw27Z9AYX6wUxZJPe9aB9NMJyhnVd6AB8Oqh k/r7cW6ys3VvN5luKUBFiJFUA9Wf8YJtJ/AQskdaMsUQAmdfXr/YRqeDIQ22oDmE = Received: (qmail 49130 invoked by alias); 11 Dec 2016 19:36:08 -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 49121 invoked by uid 89); 11 Dec 2016 19:36:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=insn_info, Hx-languages-length:2195, consideration X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Dec 2016 19:36:06 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBBJXwSC034252 for ; Sun, 11 Dec 2016 14:36:04 -0500 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 2790bfkvcf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 11 Dec 2016 14:36:04 -0500 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 11 Dec 2016 14:36:03 -0500 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 11 Dec 2016 14:36:00 -0500 Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B58156E801D; Sun, 11 Dec 2016 14:35:33 -0500 (EST) Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uBBJa0IA43319394; Sun, 11 Dec 2016 19:36:00 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25B3EAE03C; Sun, 11 Dec 2016 14:36:00 -0500 (EST) Received: from BigMac.local (unknown [9.80.220.149]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id D5228AE03B; Sun, 11 Dec 2016 14:35:59 -0500 (EST) To: GCC Patches Cc: Segher Boessenkool , David Edelsohn From: Bill Schmidt Subject: [PATCH, rs6000] Fix PR78695 Date: Sun, 11 Dec 2016 13:35:59 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121119-0056-0000-0000-0000022E696A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006225; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000196; SDB=6.00792414; UDB=6.00384065; IPR=6.00570213; BA=6.00004957; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013591; XFM=3.00000011; UTC=2016-12-11 19:36:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121119-0057-0000-0000-000006618883 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-11_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612110310 X-IsSubscribed: yes Hi, PR78695 demonstrates a bug in swap analysis where we assume that a data-flow definition contains a nonzero insn_info. This assumption is wrong at least when -fstack-protector is in effect, as the definition of the base register of the stack protector is not associated with any insn. This patch fixes the problem in the obvious way. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this ok for trunk? The problem was introduced in GCC 7, so no backports are needed. Thanks, Bill [gcc] 2016-12-11 Bill Schmidt PR target/78695 * config/rs6000/rs6000.c (find_alignment_op): Discard from consideration any definition that doesn't have an associated insn. [gcc/testsuite] 2016-12-11 Bill Schmidt PR target/78695 * gcc.target/powerpc/swaps-stack-protector.c: New test. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 243506) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -41433,6 +41433,12 @@ find_alignment_op (rtx_insn *insn, rtx base_reg) if (!base_def_link || base_def_link->next) break; + /* With stack-protector code enabled, and possibly in other + circumstances, there may not be an associated insn for + the def. */ + if (!base_def_link->ref->base.insn_info) + break; + rtx_insn *and_insn = DF_REF_INSN (base_def_link->ref); and_operation = alignment_mask (and_insn); if (and_operation != 0) Index: gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/swaps-stack-protector.c (working copy) @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fstack-protector -O3" } */ + +/* PR78695: This code used to ICE in rs6000.c:find_alignment_op because + the stack protector address definition isn't associated with an insn. */ + +void *a(); +long b() { + char c[1]; + char *d = a(), *e = c; + long f = e ? b(e) : 0; + if (f > 54) + f = 1; + while (f--) + *d++ = *e++; +}