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: 678732 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 3sqKpX6lmPz9sD5 for ; Thu, 6 Oct 2016 15:45:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FCKFR0y+; 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:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=jrwjXRy/3eu9ZEkYSvPqtyEEert3PH7TJ3bVCXDqEiibJWy0gSfdj wQjKGLxOX7LtvpeAs+x4Ptj/PgD7HeClMUIC645Ir20y95WRu1EbgbNGYPexHdj/ MikuHIB3taGWtdAY20LrPFbApo9+0hflfLUpKQQuNujshXfuj0gVuQ= 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=FCKFR0y+Fn4RO7xuUedT YtUZQl1GnwKrLBR7slbJt/FeWK0s0w51gE/xFX+UcLXDm98qnZKmZF726M55oST7 yu83q7BWMXwpg5kIWPBUmisPDLzt1rDMk8/n0WwNbzxXFnbP/7ijllcBungigz9v FOfhE5udhdhU/TjLFcn83cA= 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);