From patchwork Thu Oct 6 04:45:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 77291 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp3149424qgf; Wed, 5 Oct 2016 21:45:45 -0700 (PDT) X-Received: by 10.98.157.210 with SMTP id a79mr15159196pfk.179.1475729145518; Wed, 05 Oct 2016 21:45:45 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m10si10871917paw.157.2016.10.05.21.45.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Oct 2016 21:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-437830-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-437830-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-437830-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=gOv5sshWMR1QVZpGeRuL3alHtPSp1kN4kQPk7ewzzrD404oz5DvzX Gdl7PlwwyQrA7XoEarOckqm9uAY4w8q2bv+TRQN9m2mgExejTWtAM0nf+9t56udh 4HYAofLnad0dtjdUgn540iKrzsD6QGxZdfkYUD/m0nCMQt4PtQH7ZE= 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:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=EYnzQctkecbz3KOdrU3fKfJRUcs=; b=ZPcXfrpuR2OFsRhNBj/r yZQ1BmCmavtEcDrkvTxUlrhGfAYTorGNpHE7PA0mQFP/e+J/wGYlZ/hmL9PzYI+f SLzXD+GceYaMcpMSDxwEYOKQPsvl6coW7HwAi6bQmZwguNWehRnoGjFoiolZupWG y3f5Ap5NrWFY2uMmrwWYNaA= Received: (qmail 109309 invoked by alias); 6 Oct 2016 04:45:31 -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 109140 invoked by uid 89); 6 Oct 2016 04:45:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-HELO: mail-pf0-f178.google.com Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Oct 2016 04:45:20 +0000 Received: by mail-pf0-f178.google.com with SMTP id s13so4171536pfd.2 for ; Wed, 05 Oct 2016 21:45:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version; bh=ipyla4RGmu3gzSTwNUBr0DyalqcU2Hweru+6r+PrSpk=; b=FfzSTKzuRBsnefe3QMsEcx9aYj3FzMoCP8eBotyFK2UHU3NYZyGtgHPa+axPzaD/Za Ok/xe9a0I0S844el3YAa3UHJA451k6k8SqtDo3gBLm8OihBgU/V1gKcn+dtXlm1/nUGS +94/8Vy4Vi8TMBqOoDf9Kc2vOUKzCYTO4AOs9UdfF66GSMsSmce23/4nyEvi4ER/6fTj cxeOjYe5zlErGXQFyKhA42cXn78XsxUsw3LgQNqWoSl6MLathUBNOIAd1mPndnHtp9LB c5dRWMFBW51y7A5z2dRpVLmlughF/yhWfSjP3FMIYobflTQb52c0uaCnPb21dtQ1tyK2 fbdA== X-Gm-Message-State: AA6/9Rnb/gSysxbGm8wK5wX9HufMaQRK/eR5e6/B4MV5xk+DjpcRqWfk2eiCpEvLEfIYvQOF X-Received: by 10.98.3.67 with SMTP id 64mr13630873pfd.14.1475729118430; Wed, 05 Oct 2016 21:45:18 -0700 (PDT) Received: from [10.1.1.7] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id a1sm1157378pfl.69.2016.10.05.21.45.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Oct 2016 21:45:17 -0700 (PDT) From: kugan Subject: [PR77862] ICE in add_equivalence To: "gcc-patches@gcc.gnu.org" Message-ID: <9d990d11-b566-062e-6258-81ec60c8c994@linaro.org> Date: Thu, 6 Oct 2016 15:45:14 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, In VRP we can generate new SSA variables while performing the propagation, at least in EVRP. Therefore, when we access array vr_values we have to check num_vr_values. This caused ICE for the PR77862. Attached patch fixes this. Bootstrapped and regression tested on x86_64-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/testsuite/ChangeLog: 2016-10-06 Kugan Vivekanandarajah PR tree-optimization/77862 * gcc.dg/pr77862.c: New test. gcc/ChangeLog: 2016-10-06 Kugan Vivekanandarajah PR tree-optimization/77862 * tree-vrp.c (add_equivalence): Use get_value_range so that num_vr_values is checked before accessing vr_values. diff --git a/gcc/testsuite/gcc.dg/pr77862.c b/gcc/testsuite/gcc.dg/pr77862.c index e69de29..e9096d2 100644 --- a/gcc/testsuite/gcc.dg/pr77862.c +++ b/gcc/testsuite/gcc.dg/pr77862.c @@ -0,0 +1,19 @@ + +/* PR tree-optimization/77862 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fPIC -w" } */ + +struct paramed_type +{ +}; +int a; + +int memcmp ( int*, void *, long ); + +void +cur_token (void) +{ + if ( 1 != a || memcmp ( cur_token, "", a ) ) + return; + struct paramed_type b = { }; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index bfb6b2f..db9dc23 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -843,7 +843,7 @@ static void add_equivalence (bitmap *equiv, const_tree var) { unsigned ver = SSA_NAME_VERSION (var); - value_range *vr = vr_value[ver]; + value_range *vr = get_value_range (var); if (*equiv == NULL) *equiv = BITMAP_ALLOC (&vrp_equiv_obstack);