diff mbox series

[2/2] aarch64: Use a global map to detect duplicated overloads [PR112989]

Message ID mpt4jfispfv.fsf@arm.com
State New
Headers show
Series [1/2] aarch64: Use a separate group for SME builtins [PR112989] | expand

Commit Message

Richard Sandiford Jan. 12, 2024, 12:31 p.m. UTC
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 mbox series

Patch

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_function *, va_gc> *registered_functions;
    overloaded functions.  */
 static hash_table<registered_function_hasher> *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<tree, registered_function *> *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<tree, registered_function *>::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<nofree_string_hash, registered_function *> m_overload_names;
 };
 
 /* A base class for handling calls to built-in functions.  */