From patchwork Fri Jan 12 12:31:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1886005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TBLX05Qntz1yP3 for ; Fri, 12 Jan 2024 23:32:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B432438582AF for ; Fri, 12 Jan 2024 12:32:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id AE31C3858C36 for ; Fri, 12 Jan 2024 12:31:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE31C3858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE31C3858C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705062712; cv=none; b=xySrQ1qGJbPkBhkAALd6HqUYcJmWq3GvZ91rbpY1E+jyd3zFFkJhHBCiTvE86xn4TxfjpZ5uDPdFb9lytmVd2GduH2o3HARPbiz56Dhdq1Mdwj7UQUaQl5YjLA92Frfu7hu/DyBEUcdwRnBRWixrXTjNZTvUKYN2DvBKUd8BMxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705062712; c=relaxed/simple; bh=sN04BGjluT4ZjAIgdwcQ4NSEy5rwAlDrOzdiAq5p/Cw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=F1NXpvVrdjjOXx480DAP8gwdzU+F1w0AOWtIEwX9NF5QIStltkSbT01ajgfDurr2AJTvoXobrCj+lbJ+e9Ub4XtN9MHyY4apHR1uD2EsXyzrn0ZpeRi8kBL2/eZ5WnwwKaSDy+DRhHmUd1qCZPxK6J73buqw+OUGIPoFTBz8Sw0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A4D971FB for ; Fri, 12 Jan 2024 04:32:36 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D7403F73F for ; Fri, 12 Jan 2024 04:31:49 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH 2/2] aarch64: Use a global map to detect duplicated overloads [PR112989] References: Date: Fri, 12 Jan 2024 12:31:48 +0000 In-Reply-To: (Richard Sandiford's message of "Fri, 12 Jan 2024 12:31:09 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org As explained in the covering note to the previous patch, the fact that aarch64-sve-* is now used for multiple header files means that function_builder::add_overloaded_function now needs to use a global map to detect duplicated overload functions, instead of the member variable that it used previously. Tested on aarch64-linux-gnu & pushed. Richard gcc/ PR target/112989 * config/aarch64/aarch64-sve-builtins.h (function_builder::m_overload_names): Replace with... * config/aarch64/aarch64-sve-builtins.cc (overload_names): ...this new global. (add_overloaded_function): Update accordingly, using get_identifier to get a GGC-friendly record of the name. --- gcc/config/aarch64/aarch64-sve-builtins.cc | 22 ++++++++++++++-------- gcc/config/aarch64/aarch64-sve-builtins.h | 4 ---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index 3ad2271d51c..c2f1486315f 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -938,6 +938,10 @@ static GTY(()) vec *registered_functions; overloaded functions. */ static hash_table *function_table; +/* Maps all overloaded function names that we've registered so far to + their associated function_instances. The map keys are IDENTIFIER_NODEs. */ +static GTY(()) hash_map *overload_names; + /* True if we've already complained about attempts to use functions when the required extension is disabled. */ static bool reported_missing_extension_p; @@ -1585,21 +1589,23 @@ function_builder:: add_overloaded_function (const function_instance &instance, aarch64_feature_flags required_extensions) { + if (!overload_names) + overload_names = hash_map::create_ggc (); + char *name = get_name (instance, true); - if (registered_function **map_value = m_overload_names.get (name)) - { - gcc_assert ((*map_value)->instance == instance - && ((*map_value)->required_extensions - & ~required_extensions) == 0); - obstack_free (&m_string_obstack, name); - } + tree id = get_identifier (name); + if (registered_function **map_value = overload_names->get (id)) + gcc_assert ((*map_value)->instance == instance + && ((*map_value)->required_extensions + & ~required_extensions) == 0); else { registered_function &rfn = add_function (instance, name, m_overload_type, NULL_TREE, required_extensions, true, m_direct_overloads); - m_overload_names.put (name, &rfn); + overload_names->put (id, &rfn); } + obstack_free (&m_string_obstack, name); } /* If we are using manual overload resolution, add one function decl diff --git a/gcc/config/aarch64/aarch64-sve-builtins.h b/gcc/config/aarch64/aarch64-sve-builtins.h index 2bb893af7dd..e66729ed635 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.h +++ b/gcc/config/aarch64/aarch64-sve-builtins.h @@ -453,10 +453,6 @@ private: /* Used for building up function names. */ obstack m_string_obstack; - - /* Maps all overloaded function names that we've registered so far - to their associated function_instances. */ - hash_map m_overload_names; }; /* A base class for handling calls to built-in functions. */