]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cgraphunit.c (handle_alias_pairs): New function.
authorJan Hubicka <jh@suse.cz>
Wed, 15 Jun 2011 12:01:17 +0000 (14:01 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 15 Jun 2011 12:01:17 +0000 (12:01 +0000)
* cgraphunit.c (handle_alias_pairs): New function.
(cgraph_finalize_compilation_unit): Use it.
* ipa.c (cgraph_externally_visible_p): Remove hack marking asm names
as externally visible.

From-SVN: r175079

gcc/ChangeLog
gcc/cgraphunit.c
gcc/ipa.c

index d52725cadf852de3e295c5a7aeccddc46d7c9e7b..142856a5b478818fa6fcae0d0dbe20beffedcfe8 100644 (file)
@@ -1,3 +1,10 @@
+2011-06-13  Jan Hubicka  <jh@suse.cz>
+
+       * cgraphunit.c (handle_alias_pairs): New function.
+       (cgraph_finalize_compilation_unit): Use it.
+       * ipa.c (cgraph_externally_visible_p): Remove hack marking asm names
+       as externally visible.
+
 2011-06-15  Richard Guenther  <rguenther@suse.de>
 
        * expr.c (expand_expr_real_2): Reduce all integral types to
index 0e7842cd896f9d27f8ed7ea4a7bc6ddc85f437b4..88d0face01036a86e42dae49ea96ef7af56ebfae 100644 (file)
@@ -1175,6 +1175,49 @@ cgraph_analyze_functions (void)
   ggc_collect ();
 }
 
+/* Translate the ugly representation of aliases as alias pairs into nice
+   representation in callgraph.  We don't handle all cases yet,
+   unforutnately.  */
+
+static void
+handle_alias_pairs (void)
+{
+  alias_pair *p;
+  unsigned i;
+  struct cgraph_node *target_node;
+  struct cgraph_node *src_node;
+  
+  for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p);)
+    {
+      if (TREE_CODE (p->decl) == FUNCTION_DECL
+          && !lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl))
+         && (target_node = cgraph_node_for_asm (p->target)) != NULL)
+       {
+         src_node = cgraph_get_node (p->decl);
+         if (src_node && src_node->local.finalized)
+            cgraph_reset_node (src_node);
+         /* Normally EXTERNAL flag is used to mark external inlines,
+            however for aliases it seems to be allowed to use it w/o
+            any meaning. See gcc.dg/attr-alias-3.c  
+            However for weakref we insist on EXTERNAL flag being set.
+            See gcc.dg/attr-alias-5.c  */
+         if (DECL_EXTERNAL (p->decl))
+           DECL_EXTERNAL (p->decl) = 0;
+         cgraph_create_function_alias (p->decl, target_node->decl);
+         VEC_unordered_remove (alias_pair, alias_pairs, i);
+       }
+      else
+       {
+         if (dump_file)
+           fprintf (dump_file, "Unhandled alias %s->%s\n",
+                    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (p->decl)),
+                    IDENTIFIER_POINTER (p->target));
+
+         i++;
+       }
+    }
+}
+
 
 /* Analyze the whole compilation unit once it is parsed completely.  */
 
@@ -1200,6 +1243,7 @@ cgraph_finalize_compilation_unit (void)
 
   /* Mark alias targets necessary and emit diagnostics.  */
   finish_aliases_1 ();
+  handle_alias_pairs ();
 
   if (!quiet_flag)
     {
@@ -1216,6 +1260,7 @@ cgraph_finalize_compilation_unit (void)
 
   /* Mark alias targets necessary and emit diagnostics.  */
   finish_aliases_1 ();
+  handle_alias_pairs ();
 
   /* Gimplify and lower thunks.  */
   cgraph_analyze_functions ();
index 62510c620df9b96870ee90598338f11e5b6cb575..b9ae579cd4505ff4dcd69384e0e9abedda00f858 100644 (file)
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -612,14 +612,6 @@ cgraph_externally_visible_p (struct cgraph_node *node,
   if (DECL_BUILT_IN (node->decl))
     return true;
 
-  /* FIXME: We get wrong symbols with asm aliases in callgraph and LTO.
-     This is because very little of code knows that assembler name needs to
-     mangled.  Avoid touching declarations with user asm name set to mask
-     some of the problems.  */
-  if (DECL_ASSEMBLER_NAME_SET_P (node->decl)
-      && IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl))[0]=='*')
-    return true;
-
   /* If linker counts on us, we must preserve the function.  */
   if (cgraph_used_from_object_file_p (node))
     return true;