From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33141 invoked by alias); 11 Feb 2020 18:42:26 -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 32191 invoked by uid 89); 11 Feb 2020 18:42:25 -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) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Feb 2020 18:42:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581446543; 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=xZteFDuGzW0r1sg+hb0A5BMz5k30YSh4xvcpYSlF6Hs=; b=KSco1DsDivMSnGjHMnSbvayMUVO7N+l1QhiZcIKbftWinOx1Xm2a6S4lp/pC/GQNf1XKlo 2/VnXfG7NTSaAjNvBbsyMkKt2kc8xJ/Etx6rPC7rszWEtUr7KasCPwZ91r1s+VV+DGAbgt yeRudYe/KVk1g6VhpyoWTlnn232ZxwA= 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-365-MYsusYcGOheL9vEyQ9JlBw-1; Tue, 11 Feb 2020 13:42:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B440D800EBB for ; Tue, 11 Feb 2020 18:42:13 +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 531175D9CA; Tue, 11 Feb 2020 18:42:13 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed] analyzer: fix ICE in "__analyzer_dump_exploded_nodes" on non-empty worklist (PR 93669) Date: Tue, 11 Feb 2020 18:42:00 -0000 Message-Id: <20200211184212.5316-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/msg00672.txt.bz2 Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to master as r10-6581-ga0e4929b0461226722d6d08b1fdc2852b9100b75. gcc/analyzer/ChangeLog: PR analyzer/93669 * engine.cc (exploded_graph::dump_exploded_nodes): Handle missing case of STATUS_WORKLIST in implementation of "__analyzer_dump_exploded_nodes". gcc/testsuite/ChangeLog: PR analyzer/93669 * gcc.dg/analyzer/pr93669.c: New test. --- gcc/analyzer/engine.cc | 17 +++++++++++++---- gcc/testsuite/gcc.dg/analyzer/pr93669.c | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr93669.c diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 63579da953a..8d5f9c69724 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -3197,15 +3197,15 @@ exploded_graph::dump_exploded_nodes () const =20 /* Emit a warning at any call to "__analyzer_dump_exploded_nodes", giving the number of processed exploded nodes for "before-stmt", - and the IDs of processed and merger enodes. + and the IDs of processed, merger, and worklist enodes. =20 We highlight the count of *processed* enodes since this is of most interest in DejaGnu tests for ensuring that state merger has happened. =20 - We don't show the count of merger enodes, as this is more of an - implementation detail of the merging that we don't want to bake - into our expected DejaGnu messages. */ + We don't show the count of merger and worklist enodes, as this is + more of an implementation detail of the merging/worklist that we + don't want to bake into our expected DejaGnu messages. */ =20 unsigned i; exploded_node *enode; @@ -3225,6 +3225,7 @@ exploded_graph::dump_exploded_nodes () const =20 auto_vec processed_enodes; auto_vec merger_enodes; + auto_vec worklist_enodes; /* This is O(N^2). */ unsigned j; exploded_node *other_enode; @@ -3237,6 +3238,9 @@ exploded_graph::dump_exploded_nodes () const { default: gcc_unreachable (); + case exploded_node::STATUS_WORKLIST: + worklist_enodes.safe_push (other_enode); + break; case exploded_node::STATUS_PROCESSED: processed_enodes.safe_push (other_enode); break; @@ -3254,6 +3258,11 @@ exploded_graph::dump_exploded_nodes () const pp_string (&pp, "] merger(s): ["); print_enode_indices (&pp, merger_enodes); } + if (worklist_enodes.length () > 0) + { + pp_string (&pp, "] worklist: ["); + print_enode_indices (&pp, worklist_enodes); + } pp_character (&pp, ']'); =20 warning_n (stmt->location, 0, processed_enodes.length (), diff --git a/gcc/testsuite/gcc.dg/analyzer/pr93669.c b/gcc/testsuite/gcc.dg= /analyzer/pr93669.c new file mode 100644 index 00000000000..01e266dd3f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr93669.c @@ -0,0 +1,25 @@ +/* { dg-additional-options "--param analyzer-max-enodes-per-program-point= =3D2 -Wno-analyzer-too-complex" } */ + +#include "analyzer-decls.h" + +int test (int a) +{ + if (a !=3D 42 && a !=3D 113) { + return (-2); + } + + __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" = } */ + + return 0; +} + +int test_2 (int a) +{ + if (a !=3D 42 && a !=3D 113 && a !=3D 666) { + return (-2); + } + + __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" = } */ + + return 0; +} --=20 2.21.0