From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62458 invoked by alias); 17 Oct 2018 18:15:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 61880 invoked by uid 89); 17 Oct 2018 18:15:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KHOP_DYNAMIC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=unavailable version=3.3.2 spammy=H*Ad:D*ibm.com, 2190 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Oct 2018 18:15:03 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9HHrl9G099178 for ; Wed, 17 Oct 2018 14:15:01 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n68yd3a6r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Oct 2018 14:15:01 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Oct 2018 19:14:58 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 17 Oct 2018 19:14:57 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9HIEtX741287868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Oct 2018 18:14:55 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E564AE051; Wed, 17 Oct 2018 18:14:55 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F22A3AE045; Wed, 17 Oct 2018 18:14:54 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.145.29.125]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 17 Oct 2018 18:14:54 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org Cc: vmakarov@gcc.gnu.org, asolokha@gmx.com, bergner@vnet.ibm.com, krebbel@linux.ibm.com, rdapp@linux.ibm.com, Ilya Leoshkevich Subject: [PATCH v2] lra: fix spill_hard_reg_in_range clobber check Date: Wed, 17 Oct 2018 21:17:00 -0000 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit x-cbid: 18101718-0020-0000-0000-000002D58EC2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101718-0021-0000-0000-00002124A3B5 Message-Id: <20181017181452.42584-1-iii@linux.ibm.com> X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg01055.txt.bz2 Boostrapped and regtested on x86_64-redhat-linux. Changes since v1: * Added the missing INSN_P () check. * Rewrote the commit message. FROM..TO range might contain NOTE_INSN_DELETED insns, for which the corresponding entries in lra_insn_recog_data[] are NULLs. Example from the problematic code from PR87596: (note 148 154 68 7 NOTE_INSN_DELETED) lra_insn_recog_data[] is used directly only when the insn in question is taken from insn_bitmap, which is not the case here. In other situations lra_get_insn_recog_data () guarded by INSN_P () or other stricter predicate are used. So we need to do this here as well. A tiny detail worth noting: I put the INSN_P () check before the insn_bitmap check, because I believe that insn_bitmap can contain only real insns anyway. gcc/ChangeLog: 2018-10-16 Ilya Leoshkevich PR rtl-optimization/87596 * lra-constraints.c (spill_hard_reg_in_range): Use INSN_P () + lra_get_insn_recog_data () instead of lra_insn_recog_data[] for instructions in FROM..TO range. gcc/testsuite/ChangeLog: 2018-10-16 Ilya Leoshkevich PR rtl-optimization/87596 * gcc.target/i386/pr87596.c: New test. --- gcc/lra-constraints.c | 9 ++++++--- gcc/testsuite/gcc.target/i386/pr87596.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr87596.c diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 774d1ff3aaa..3cbe0465a87 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -5696,12 +5696,15 @@ spill_hard_reg_in_range (int regno, enum reg_class rclass, rtx_insn *from, rtx_i continue; for (insn = from; insn != NEXT_INSN (to); insn = NEXT_INSN (insn)) { - lra_insn_recog_data_t id = lra_insn_recog_data[uid = INSN_UID (insn)]; - struct lra_static_insn_data *static_id = id->insn_static_data; + struct lra_static_insn_data *static_id; struct lra_insn_reg *reg; - if (bitmap_bit_p (&lra_reg_info[hard_regno].insn_bitmap, uid)) + if (!INSN_P (insn)) + continue; + if (bitmap_bit_p (&lra_reg_info[hard_regno].insn_bitmap, + INSN_UID (insn))) break; + static_id = lra_get_insn_recog_data (insn)->insn_static_data; for (reg = static_id->hard_regs; reg != NULL; reg = reg->next) if (reg->regno == hard_regno) break; diff --git a/gcc/testsuite/gcc.target/i386/pr87596.c b/gcc/testsuite/gcc.target/i386/pr87596.c new file mode 100644 index 00000000000..764708b694a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr87596.c @@ -0,0 +1,16 @@ +/* LRA corner case which triggered a segfault. */ +/* Reduced testcase by Arseny Solokha. */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O1 -fschedule-insns -ftrapv -funroll-all-loops -fno-tree-dominator-opts -fno-tree-loop-im" } */ + +void +wh (__int128 *ku) +{ + unsigned int *dp; + + while (*ku < 1) + { + *dp <<= 32; /* { dg-warning "left shift count >= width of type" } */ + ++*ku; + } +} -- 2.19.0