From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109789 invoked by alias); 11 Feb 2020 18:41:48 -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 109775 invoked by uid 89); 11 Feb 2020 18:41:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 18:41:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581446505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v+1VhCBe9vDF5NnULeZuH8LgRqRMBtJ7CMCGZ9uFiKQ=; b=XW3oDH4EVEHhMJ6jNDeEEJWKwAOmcvWd68kgYmCrlijNmFUU/khnf6Mbfm/lurSqccGLfH 9lIeYnDOgY1Uav+3ONW970d3lq1xbuQxV72Rj4TVoaaQ+O4bN3J7ETzIqEL6iOFHL6E3JX Qjz50v18XTNFTUrlazKWOp5T5cjTO6M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-348-CTTBxW83PKSooggCj1Bwaw-1; Tue, 11 Feb 2020 13:41:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9D56802722 for ; Tue, 11 Feb 2020 18:41:32 +0000 (UTC) Received: from t470.redhat.com (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id D422E60BF1; Tue, 11 Feb 2020 18:41:30 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] analyzer: fix ICE with equiv_class constant (PR 93649) Date: Tue, 11 Feb 2020 18:41:00 -0000 Message-Id: <20200211184128.5109-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00671.txt.bz2 Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to master as r10-6580-gcd28b75921354c64fd4c8a1c238991e522abc38e. gcc/analyzer/ChangeLog: PR analyzer/93649 * constraint-manager.cc (constraint_manager::add_constraint): When merging equivalence classes and updating m_constant, also update m_cst_sid. (constraint_manager::validate): If m_constant is non-NULL assert that m_cst_sid is non-null and is valid. gcc/testsuite/ChangeLog: PR analyzer/93649 * gcc.dg/analyzer/torture/pr93649.c: New test. --- gcc/analyzer/constraint-manager.cc | 8 ++- .../gcc.dg/analyzer/torture/pr93649.c | 66 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-m= anager.cc index d5a6939e714..a6235435681 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -686,8 +686,8 @@ constraint_manager::add_constraint (equiv_class_id lhs_= ec_id, =20 if (rhs_ec_obj.m_constant) { - //gcc_assert (lhs_ec_obj.m_constant =3D=3D NULL); lhs_ec_obj.m_constant =3D rhs_ec_obj.m_constant; + lhs_ec_obj.m_cst_sid =3D rhs_ec_obj.m_cst_sid; } =20 /* Drop rhs equivalence class, overwriting it with the @@ -1516,7 +1516,11 @@ constraint_manager::validate () const gcc_assert (sid->as_int () < get_num_svalues ()); } if (ec->m_constant) - gcc_assert (CONSTANT_CLASS_P (ec->m_constant)); + { + gcc_assert (CONSTANT_CLASS_P (ec->m_constant)); + gcc_assert (!ec->m_cst_sid.null_p ()); + gcc_assert (ec->m_cst_sid.as_int () < get_num_svalues ()); + } #if 0 else gcc_assert (ec->m_vars.length () > 0); diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c b/gcc/testsuit= e/gcc.dg/analyzer/torture/pr93649.c new file mode 100644 index 00000000000..9d929395bb4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c @@ -0,0 +1,66 @@ +/* { dg-additional-options "-Wno-incompatible-pointer-types -Wno-analyzer-= too-complex" } */ +/* TODO: ideally we shouldn't have -Wno-analyzer-too-complex above; it + appears to be needed due to the recursion. */ + +struct tz { + int qc; +}; + +struct wp { + struct tz *p2; +} *ov; + +struct dz { + struct wp *r5; +}; + +void +za (void); + +void +h5 (struct dz *); + +int +e7 (struct wp *f2) +{ + return f2 =3D=3D ov; +} + +void +wr (struct wp *sw) +{ + if (sw !=3D 0) + za (); +} + +void +m6 (const struct dz *gq) +{ + wr (gq->r5); + + asm ("" : "+m" (gq)); + + if (0) + { + asm ("" : "+m" (gq->r5->p2->qc)); + asm ("" : "+m" (gq->r5->p2->qc)); + } + + asm ("" : "+m" (gq->r5->p2->qc)); + + if (e7 (gq->r5)) + za (); +} + +void +ts (struct dz *cx) +{ + struct dz nt; + + if (nt.r5) + { + m6 (cx); + h5 (cx); + ts (&cx); + } +} --=20 2.21.0