From patchwork Tue Feb 11 18:42:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1236430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519362-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=ugkt0vBD; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KSco1DsD; dkim-atps=neutral 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 48HBTk2NgWz9sP7 for ; Wed, 12 Feb 2020 05:42:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=J+ZNEGRre4N/CCEQ l0CtWn5aYf8oigWpcp2na5B5dtsWjIiA5F5L2xntBKEAD/GvrB87ngx+i+FRVcMB Sw+K+Q1kcP+hVaPhCbsCaNV2JMnZBvCeUigJBPC78NjxtSnqJfU1IosV4XL0b30g 4G4DtPAW7CwFoCA7lyP1CPIeXDo= 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 :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=gxl9HsCi6OJP08isJ3bfup 2Qzbo=; b=ugkt0vBDx/o4z5e63ZTwnBG1HcQm73NkFalmIs84WEpEy0sPldJpgI zVS5SGlKWhkFUw+yeEjCq0ZfZUcVHRgW6ip1Ru7N/aB+tGkz9wP8bsiF3T+K/S3f 9Uyuu21hBZN6e+l81aPjOfw9wUeEAULsSNQIO0IPVbN2skolvYF1c= 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-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 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 13:42:12 -0500 Message-Id: <20200211184212.5316-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes 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 /* 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. We highlight the count of *processed* enodes since this is of most interest in DejaGnu tests for ensuring that state merger has happened. - 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. */ unsigned i; exploded_node *enode; @@ -3225,6 +3225,7 @@ exploded_graph::dump_exploded_nodes () const 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, ']'); 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=2 -Wno-analyzer-too-complex" } */ + +#include "analyzer-decls.h" + +int test (int a) +{ + if (a != 42 && a != 113) { + return (-2); + } + + __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ + + return 0; +} + +int test_2 (int a) +{ + if (a != 42 && a != 113 && a != 666) { + return (-2); + } + + __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ + + return 0; +}