Fix two ICEs seen in Mozilla LTO build

Jan Hubicka hubicka@ucw.cz
Tue Jun 4 23:01:00 GMT 2013


Hi,
my changes to visibility flag broke on Mozilla in two interesting way.  First
is ICE in get_alias_symbol. Until now I was not aware that C++ FE can create
same body aliases for external symbols.  Most of the symtab code deals with it
as with weakrefs that works by accident rather than design.  I have patch in
queue to clean this up, but since I decided to rewrite it once again, I am fixing
at least this ICE.

The other is latent problem in can_refer_from_this_unit_p that expect symtab nodes
to exist for everything at ltrans stage while they are in fact removed by
symtab_remove_unreachable_nodes

Bootstrapped/regtested x86_64-linux.

Honza

2013-06-04  Jan Hubicka  <jh@suse.cz>

        * lto-cgraph.c (get_alias_symbol): Remove weakref sanity check.
        (input_node, input_varpool_node): Handle correctly external same
        body aliases.
        * ipa.c (symtab_remove_unreachable_nodes): Do not remove external
        nodes at ltrans stage.

Index: lto-cgraph.c
===================================================================
*** lto-cgraph.c	(revision 199608)
--- lto-cgraph.c	(working copy)
*************** static tree
*** 918,924 ****
  get_alias_symbol (tree decl)
  {
    tree alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
-   gcc_assert (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)));
    return get_identifier (TREE_STRING_POINTER
  			  (TREE_VALUE (TREE_VALUE (alias))));
  }
--- 921,926 ----
*************** input_node (struct lto_file_decl_data *f
*** 1008,1014 ****
        node->thunk.virtual_value = virtual_value;
        node->thunk.virtual_offset_p = (type & 4);
      }
!   if (node->symbol.alias && !node->symbol.analyzed)
      node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
    return node;
  }
--- 1010,1017 ----
        node->thunk.virtual_value = virtual_value;
        node->thunk.virtual_offset_p = (type & 4);
      }
!   if (node->symbol.alias && !node->symbol.analyzed
!       && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
      node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
    return node;
  }
*************** input_varpool_node (struct lto_file_decl
*** 1050,1056 ****
        DECL_EXTERNAL (node->symbol.decl) = 1;
        TREE_STATIC (node->symbol.decl) = 0;
      }
!   if (node->symbol.alias && !node->symbol.analyzed)
      node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
    ref = streamer_read_hwi (ib);
    /* Store a reference for now, and fix up later to be a pointer.  */
--- 1054,1061 ----
        DECL_EXTERNAL (node->symbol.decl) = 1;
        TREE_STATIC (node->symbol.decl) = 0;
      }
!   if (node->symbol.alias && !node->symbol.analyzed
!       && lookup_attribute ("weakref", DECL_ATTRIBUTES (node->symbol.decl)))
      node->symbol.alias_target = get_alias_symbol (node->symbol.decl);
    ref = streamer_read_hwi (ib);
    /* Store a reference for now, and fix up later to be a pointer.  */
Index: ipa.c
===================================================================
*** ipa.c	(revision 199608)
--- ipa.c	(working copy)
*************** symtab_remove_unreachable_nodes (bool be
*** 387,393 ****
    for (vnode = varpool_first_variable (); vnode; vnode = vnext)
      {
        vnext = varpool_next_variable (vnode);
!       if (!vnode->symbol.aux)
  	{
  	  if (file)
  	    fprintf (file, " %s", varpool_node_name (vnode));
--- 387,397 ----
    for (vnode = varpool_first_variable (); vnode; vnode = vnext)
      {
        vnext = varpool_next_variable (vnode);
!       if (!vnode->symbol.aux
! 	  /* For can_refer_decl_in_current_unit_p we want to track for
! 	     all external variables if they are defined in other partition
! 	     or not.  */
! 	  && (!flag_ltrans || !DECL_EXTERNAL (vnode->symbol.decl)))
  	{
  	  if (file)
  	    fprintf (file, " %s", varpool_node_name (vnode));



More information about the Gcc-patches mailing list