]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Use a global map to detect duplicated overloads [PR112989]
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 12 Jan 2024 12:29:22 +0000 (12:29 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 12 Jan 2024 12:29:22 +0000 (12:29 +0000)
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.

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
gcc/config/aarch64/aarch64-sve-builtins.h

index 3ad2271d51c10b3759d2cef94284cf931a1f2c54..c2f1486315f02c3e38f808b3124a9b4cf49a4708 100644 (file)
@@ -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
index 2bb893af7dd7d23e7d0fdf135db304cdc059907c..e66729ed63532811b3b16ab57ae11cb10518caca 100644 (file)
@@ -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.  */