[PATCH] Fix PR50601

Richard Guenther rguenther@suse.de
Tue Dec 6 13:08:00 GMT 2011


This moves the alias quirk handling from assemble_alias to
its caller, rest_of_decl_compilation.  There it is guarded
by !in_lto_p and thus the LTO partitioning related issue
(it marks the alias DECL_EXTERNAL and requires that to stay so)
does not trigger.  Source quirk moving up the call stack sounds
good - eventually the FEs should drop the DECL_EXTERNAL already.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-12-06  Richard Guenther  <rguenther@suse.de>

	PR middle-end/50601
	* varasm.c (assemble_alias): Move DECL_EXTERNAL implementation
	quirk adjustjment ...
	* passes.c (rest_of_decl_compilation): ... here.

Index: gcc/passes.c
===================================================================
--- gcc/passes.c	(revision 182041)
+++ gcc/passes.c	(working copy)
@@ -156,6 +156,11 @@ rest_of_decl_compilation (tree decl,
       {
 	alias = TREE_VALUE (TREE_VALUE (alias));
 	alias = get_identifier (TREE_STRING_POINTER (alias));
+	/* A quirk of the initial implementation of aliases required that the
+	   user add "extern" to all of them.  Which is silly, but now
+	   historical.  Do note that the symbol is in fact locally defined.  */
+	if (!lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
+	  DECL_EXTERNAL (decl) = 0;
 	assemble_alias (decl, alias);
       }
   }
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 182043)
+++ gcc/varasm.c	(working copy)
@@ -5794,14 +5794,11 @@ void
 assemble_alias (tree decl, tree target)
 {
   tree target_decl;
-  bool is_weakref = false;
 
   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
     {
       tree alias = DECL_ASSEMBLER_NAME (decl);
 
-      is_weakref = true;
-
       ultimate_transparent_alias_target (&target);
 
       if (alias == target)
@@ -5839,12 +5836,6 @@ assemble_alias (tree decl, tree target)
     }
   TREE_USED (decl) = 1;
 
-  /* A quirk of the initial implementation of aliases required that the user
-     add "extern" to all of them.  Which is silly, but now historical.  Do
-     note that the symbol is in fact locally defined.  */
-  if (! is_weakref)
-    DECL_EXTERNAL (decl) = 0;
-
   /* Allow aliases to aliases.  */
   if (TREE_CODE (decl) == FUNCTION_DECL)
     cgraph_get_create_node (decl)->alias = true;



More information about the Gcc-patches mailing list