From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: David Malcolm 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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-List-Received-Date: Wed, 20 Jul 2022 00:25:21 -0000 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); -- 2.26.3