Example #1
0
void
lto_symtab_merge_symbols (void)
{
  symtab_node node;

  if (!flag_ltrans)
    {
      symtab_initialize_asm_name_hash ();

      /* Do the actual merging.  
         At this point we invalidate hash translating decls into symtab nodes
	 because after removing one of duplicate decls the hash is not correcly
	 updated to the ohter dupliate.  */
      FOR_EACH_SYMBOL (node)
	if (lto_symtab_symbol_p (node)
	    && node->symbol.next_sharing_asm_name
	    && !node->symbol.previous_sharing_asm_name)
	  lto_symtab_merge_symbols_1 (node);

      /* Resolve weakref aliases whose target are now in the compilation unit.  
	 also re-populate the hash translating decls into symtab nodes*/
      FOR_EACH_SYMBOL (node)
	{
	  cgraph_node *cnode, *cnode2;
	  if (!node->symbol.analyzed && node->symbol.alias_target)
	    {
	      symtab_node tgt = symtab_node_for_asm (node->symbol.alias_target);
	      gcc_assert (node->symbol.weakref);
	      if (tgt)
		symtab_resolve_alias (node, tgt);
	    }
	  node->symbol.aux = NULL;
	  
	  if (!(cnode = dyn_cast <cgraph_node> (node))
	      || !cnode->clone_of
	      || cnode->clone_of->symbol.decl != cnode->symbol.decl)
	    {
	      if (cnode && DECL_BUILT_IN (node->symbol.decl)
		  && (cnode2 = cgraph_get_node (node->symbol.decl))
		  && cnode2 != cnode)
		lto_cgraph_replace_node (cnode2, cnode);
	      symtab_insert_node_to_hashtable ((symtab_node)node);
	    }
	}
    }
Example #2
0
void
lto_symtab_merge_symbols (void)
{
  symtab_node *node;

  if (!flag_ltrans)
    {
      symtab->symtab_initialize_asm_name_hash ();

      /* Do the actual merging.  
         At this point we invalidate hash translating decls into symtab nodes
	 because after removing one of duplicate decls the hash is not correcly
	 updated to the ohter dupliate.  */
      FOR_EACH_SYMBOL (node)
	if (lto_symtab_symbol_p (node)
	    && node->next_sharing_asm_name
	    && !node->previous_sharing_asm_name)
	  lto_symtab_merge_symbols_1 (node);

      /* Resolve weakref aliases whose target are now in the compilation unit.  
	 also re-populate the hash translating decls into symtab nodes*/
      FOR_EACH_SYMBOL (node)
	{
	  cgraph_node *cnode, *cnode2;
	  varpool_node *vnode;
	  symtab_node *node2;

	  if (!node->analyzed && node->alias_target)
	    {
	      symtab_node *tgt = symtab_node::get_for_asmname (node->alias_target);
	      gcc_assert (node->weakref);
	      if (tgt)
		node->resolve_alias (tgt, true);
	    }
	  /* If the symbol was preempted outside IR, see if we want to get rid
	     of the definition.  */
	  if (node->analyzed
	      && !DECL_EXTERNAL (node->decl)
	      && (node->resolution == LDPR_PREEMPTED_REG
		  || node->resolution == LDPR_RESOLVED_IR
		  || node->resolution == LDPR_RESOLVED_EXEC
		  || node->resolution == LDPR_RESOLVED_DYN))
	    {
	      DECL_EXTERNAL (node->decl) = 1;
	      /* If alias to local symbol was preempted by external definition,
		 we know it is not pointing to the local symbol.  Remove it.  */
	      if (node->alias
		  && !node->weakref
		  && !node->transparent_alias
		  && node->get_alias_target ()->binds_to_current_def_p ())
		{
		  node->alias = false;
		  node->remove_all_references ();
		  node->definition = false;
		  node->analyzed = false;
		  node->cpp_implicit_alias = false;
		}
	      else if (!node->alias
		       && node->definition
		       && node->get_availability () <= AVAIL_INTERPOSABLE)
		{
		  if ((cnode = dyn_cast <cgraph_node *> (node)) != NULL)
		    cnode->reset ();
		  else
		    {
		      node->analyzed = node->definition = false;
		      node->remove_all_references ();
		    }
		}
	    }

	  if (!(cnode = dyn_cast <cgraph_node *> (node))
	      || !cnode->clone_of
	      || cnode->clone_of->decl != cnode->decl)
	    {
	      /* Builtins are not merged via decl merging.  It is however
		 possible that tree merging unified the declaration.  We
		 do not want duplicate entries in symbol table.  */
	      if (cnode && DECL_BUILT_IN (node->decl)
		  && (cnode2 = cgraph_node::get (node->decl))
		  && cnode2 != cnode)
		lto_cgraph_replace_node (cnode2, cnode);

	      /* The user defined assembler variables are also not unified by their
		 symbol name (since it is irrelevant), but we need to unify symbol
		 nodes if tree merging occurred.  */
	      if ((vnode = dyn_cast <varpool_node *> (node))
		  && DECL_HARD_REGISTER (vnode->decl)
		  && (node2 = symtab_node::get (vnode->decl))
		  && node2 != node)
		lto_varpool_replace_node (dyn_cast <varpool_node *> (node2),
					  vnode);
	  

	      /* Abstract functions may have duplicated cgraph nodes attached;
		 remove them.  */
	      else if (cnode && DECL_ABSTRACT_P (cnode->decl)
		       && (cnode2 = cgraph_node::get (node->decl))
		       && cnode2 != cnode)
		cnode2->remove ();

	      node->decl->decl_with_vis.symtab_node = node;
	    }
	}
    }