From patchwork Wed Jul 20 00:25:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 70 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2773592eik; Tue, 19 Jul 2022 17:26:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sVFS7L5Sy9V/ZX6ry3twMgfOod6ciHByGGcZ389ACGNMOgUBXL/J79M+/6ECA5Sal0R4gk X-Received: by 2002:a05:6402:428a:b0:42e:8f7e:1638 with SMTP id g10-20020a056402428a00b0042e8f7e1638mr47801050edc.228.1658276764029; Tue, 19 Jul 2022 17:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658276764; cv=none; d=google.com; s=arc-20160816; b=BysKOaC/Mux31yfBCTowN3LHBkZbYQPYXw+Lr714K5KnS5ScPstz+9YJ1aYNyf9ZsQ DiTVKzZlDiHUPGfinV/E9MLuIQYVp5XSHnKnW3OaMil44vYwrFPRWIk6ItLqDM5c0u17 Cbm37JeRmrv4qkEjrnPHP4RNE6t5BGJwG5ILRm1u826akqMT3nLCtKaDPziD55lJiklx k6uQOArECyhXdMqo6eajC6nlswyFPs7v6sAF2oE3Al7WosILlOLtxxYP8pPPuTZ22/VI m5mG8ncYrDDEanKOu95OmBhl/487OfM0hxhLNKU0RkUMkEbxV8EP/lFTxW75Q1SIG+ab q9yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+zzfQGxX1Fso6FnVFFma9Qhr1UhOj7KqzRSQkvJFaf4=; b=Yli/Hc5FHUXZawm+0dCR5uNZaHwNDMP164O3p+gcRWvJU1aCiO9UMTv0RODhfKBUFj pJOxO0FSKDT0+afRbRPVfzCad5iNl19DPB55m5PbhkIas35+jdXmRmpQoMNsnvDC5WCY krMN1yiKnGzCCsX2K4d29kbdAwUUntMJVJQNyy0S06iXFuRxUejlU/YLg0MjprV0BobQ ThtuDcRb1KFRRA50r+bkpmAFiIVqaX61M5K3yYru/bjWL3tERmQ7axtRaJOc9/yzLGE3 oB7j8hhE3gk2/sGQH5/NIbbfJJOniDgq1Z5WSJmG71CqAMRdvS+70FM8OBFnEKK7eXDW Gvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=V0FrUvyS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g24-20020a170906869800b00726347cbb61si16740110ejx.981.2022.07.19.17.26.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 17:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=V0FrUvyS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 04A3D385828B for ; Wed, 20 Jul 2022 00:26:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04A3D385828B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658276763; bh=+zzfQGxX1Fso6FnVFFma9Qhr1UhOj7KqzRSQkvJFaf4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=V0FrUvyS3yJOlHh3/EwLI6zpxiDkfxmrHNL6jkcJBkoKvFiFkC8fYgclr32XOHOLE eL1Onz7aFuZYDPHwUnMbYUnEr8WtURoiP1g2rN5kf0wkBfFAHTkAebNWZ8Q0lF+0nG 26waC9WtuIvWQqUUj/6nbuMiBhJRuRnmaMGVmLX8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C0A853858D37 for ; Wed, 20 Jul 2022 00:25:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C0A853858D37 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-121-d9OG5MfdPy6loSaiIMYQxA-1; Tue, 19 Jul 2022 20:25:14 -0400 X-MC-Unique: d9OG5MfdPy6loSaiIMYQxA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06D02380673B for ; Wed, 20 Jul 2022 00:25:14 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.16.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id D15012026D64; Wed, 20 Jul 2022 00:25:13 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [committed] analyzer: don't track string literals in the store [PR106359] Date: Tue, 19 Jul 2022 20:25:12 -0400 Message-Id: <20220720002512.1394423-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Malcolm via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: David Malcolm Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738829215880478869?= X-GMAIL-MSGID: =?utf-8?q?1738829215880478869?= Doing so speeds up -fanalyzer from taking over 4 hours to under a minute on the Linux kernel's sound/soc/codecs/cs47l90.c Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r13-1761-g68871a008e686d. gcc/analyzer/ChangeLog: PR analyzer/106359 * region.h (string_region::tracked_p): New. * store.cc (binding_cluster::binding_cluster): Move here from store.h. Add assertion that base_region is tracked_p. * store.h (binding_cluster::binding_cluster): Move to store.cc. Signed-off-by: David Malcolm --- gcc/analyzer/region.h | 4 ++++ gcc/analyzer/store.cc | 7 +++++++ gcc/analyzer/store.h | 4 +--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index 60d8149f513..fd0d4a05cc9 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -1151,6 +1151,10 @@ public: void dump_to_pp (pretty_printer *pp, bool simple) const final override; + /* We assume string literals are immutable, so we don't track them in + the store. */ + bool tracked_p () const final override { return false; } + tree get_string_cst () const { return m_string_cst; } private: diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index 06151d8c041..e3dabf300df 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -1103,6 +1103,13 @@ binding_map::remove_overlapping_bindings (store_manager *mgr, /* class binding_cluster. */ +binding_cluster::binding_cluster (const region *base_region) +: m_base_region (base_region), m_map (), + m_escaped (false), m_touched (false) +{ + gcc_assert (base_region->tracked_p ()); +} + /* binding_cluster's copy ctor. */ binding_cluster::binding_cluster (const binding_cluster &other) diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h index 368b2990ae8..9b54c7b9156 100644 --- a/gcc/analyzer/store.h +++ b/gcc/analyzer/store.h @@ -544,9 +544,7 @@ public: typedef hash_map map_t; typedef map_t::iterator iterator_t; - binding_cluster (const region *base_region) - : m_base_region (base_region), m_map (), - m_escaped (false), m_touched (false) {} + binding_cluster (const region *base_region); binding_cluster (const binding_cluster &other); binding_cluster& operator=(const binding_cluster &other);