http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50822

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-11-07 
15:47:08 UTC ---
Hi,
the problem seems to be due to fact that C++ FE output extern aliases.  This is
not quite documented and they was simply removed by the old alias pair handling
code (I believe by accident rather than by design), while the new code confuses
them with weakrefs and attempts to output into final assembly.

I think those aliases might potentially be useful for alias analysis and ==
folding - i.e. they provide knowledge that those two variables/functions must
be equivalent. So instead of convincing C++ FE to not output them it seems
better to make cgraph code to deal with them well. For 4.8 we may start using
the alias walkers in the alias analysis and folding to actually make use of
this.

I think it only imply need to ignore them when the functions are being output.

I am testing the attached patch that ought to solve the issue.

Index: cgraphunit.c
===================================================================
--- cgraphunit.c        (revision 181033)
+++ cgraphunit.c        (working copy)
@@ -2101,13 +2101,15 @@ output_weakrefs (void)
   struct varpool_node *vnode;
   for (node = cgraph_nodes; node; node = node->next)
     if (node->alias && DECL_EXTERNAL (node->decl)
-        && !TREE_ASM_WRITTEN (node->decl))
+        && !TREE_ASM_WRITTEN (node->decl)
+       && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->decl)))
       assemble_alias (node->decl,
                      node->thunk.alias ? DECL_ASSEMBLER_NAME
(node->thunk.alias)
                      : get_alias_symbol (node->decl));
   for (vnode = varpool_nodes; vnode; vnode = vnode->next)
     if (vnode->alias && DECL_EXTERNAL (vnode->decl)
-        && !TREE_ASM_WRITTEN (vnode->decl))
+        && !TREE_ASM_WRITTEN (vnode->decl)
+       && lookup_attribute ("weakref", DECL_ATTRIBUTES (vnode->decl)))
       assemble_alias (vnode->decl,
                      vnode->alias_of ? DECL_ASSEMBLER_NAME (vnode->alias_of)
                      : get_alias_symbol (vnode->decl));

Reply via email to