Hi,
this patch fixes ICE in varpool_node::get_availability which happens when
you dump a node with weakref and makes symbol_table::remove_unreferenced_decls
to keep aliases in the boundary so we do not lose the information that they
actually represent the same location in the binary.

This is needed to fix alias.c/tree-alias.c WRT aliases.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

Honza

        * varpool.c (varpool_node::get_availability): Recurse only on
        weakrefs with definition in the target.
        (symbol_table::remove_unreferenced_decls): Keep aliases in the boundary.
Index: varpool.c
===================================================================
--- varpool.c   (revision 231425)
+++ varpool.c   (working copy)
@@ -490,7 +490,7 @@ varpool_node::get_availability (void)
   if (DECL_IN_CONSTANT_POOL (decl)
       || DECL_VIRTUAL_P (decl))
     return AVAIL_AVAILABLE;
-  if (transparent_alias)
+  if (transparent_alias && definition)
     {
       enum availability avail;
 
@@ -667,11 +667,11 @@ symbol_table::remove_unreferenced_decls
            enqueue_node (vnode, &first);
          else
            {
-             referenced.add (node);
-             while (node->alias && node->definition)
+             referenced.add (vnode);
+             while (vnode && vnode->alias && vnode->definition)
                {
-                 node = node->get_alias_target ();
-                 referenced.add (node);
+                 vnode = vnode->get_alias_target ();
+                 referenced.add (vnode);
                }
            }
        }

Reply via email to