On Mon, 8 Apr 2013, Jan Hubicka wrote:

> Hi,
> currently lto-symtab is trying to resolve all duplicated declarations,
> including static variables where such duplicates should not happen.
> This conflicts with the plan to solve PR54095 by postponning renaming to
> the partitioning.  This patch adds lto_symtab_symbol_p that disable merging
> on statics and keeps duplicate entries for a given asm name.
> 
> Boostrapped/regtested x86_64-linux, OK?

Ok.

Thanks,
Richard.

> Honza
> 
>       PR lto/54095
>       lto-symtab.c (lto_symtab_symbol_p): New function.
>       (lto_symtab_resolve_can_prevail_p, lto_symtab_resolve_symbols,
>       lto_symtab_resolve_symbols, lto_symtab_merge_decls_2,
>       lto_symtab_merge_decls_1, lto_symtab_merge_cgraph_nodes_1):
>       Skip static symbols.
>       
> Index: lto-symtab.c
> ===================================================================
> *** lto-symtab.c      (revision 197551)
> --- lto-symtab.c      (working copy)
> *************** lto_symtab_resolve_replaceable_p (symtab
> *** 226,237 ****
>     return false;
>   }
>   
>   /* Return true if the symtab entry E can be the prevailing one.  */
>   
>   static bool
>   lto_symtab_resolve_can_prevail_p (symtab_node e)
>   {
> !   if (!symtab_real_symbol_p (e))
>       return false;
>   
>     /* The C++ frontend ends up neither setting TREE_STATIC nor
> --- 226,249 ----
>     return false;
>   }
>   
> + /* Return true, if the symbol E should be resolved by lto-symtab.
> +    Those are all real symbols that are not static (we handle renaming
> +    of static later in partitioning).  */
> + 
> + static bool
> + lto_symtab_symbol_p (symtab_node e)
> + {
> +   if (!TREE_PUBLIC (e->symbol.decl))
> +     return false;
> +   return symtab_real_symbol_p (e);
> + }
> + 
>   /* Return true if the symtab entry E can be the prevailing one.  */
>   
>   static bool
>   lto_symtab_resolve_can_prevail_p (symtab_node e)
>   {
> !   if (!lto_symtab_symbol_p (e))
>       return false;
>   
>     /* The C++ frontend ends up neither setting TREE_STATIC nor
> *************** lto_symtab_resolve_symbols (symtab_node
> *** 261,267 ****
>   
>     /* Always set e->node so that edges are updated to reflect decl merging. 
> */
>     for (e = first; e; e = e->symbol.next_sharing_asm_name)
> !     if (symtab_real_symbol_p (e)
>       && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
>           || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
>           || e->symbol.resolution == LDPR_PREVAILING_DEF))
> --- 273,279 ----
>   
>     /* Always set e->node so that edges are updated to reflect decl merging. 
> */
>     for (e = first; e; e = e->symbol.next_sharing_asm_name)
> !     if (lto_symtab_symbol_p (e)
>       && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
>           || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
>           || e->symbol.resolution == LDPR_PREVAILING_DEF))
> *************** lto_symtab_resolve_symbols (symtab_node
> *** 275,281 ****
>       {
>         /* Assert it's the only one.  */
>         for (e = prevailing->symbol.next_sharing_asm_name; e; e = 
> e->symbol.next_sharing_asm_name)
> !     if (symtab_real_symbol_p (e)
>           && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
>               || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
>               || e->symbol.resolution == LDPR_PREVAILING_DEF))
> --- 287,293 ----
>       {
>         /* Assert it's the only one.  */
>         for (e = prevailing->symbol.next_sharing_asm_name; e; e = 
> e->symbol.next_sharing_asm_name)
> !     if (lto_symtab_symbol_p (e)
>           && (e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY
>               || e->symbol.resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
>               || e->symbol.resolution == LDPR_PREVAILING_DEF))
> *************** lto_symtab_resolve_symbols (symtab_node
> *** 310,317 ****
>     /* Do a second round choosing one from the replaceable prevailing decls.  
> */
>     for (e = first; e; e = e->symbol.next_sharing_asm_name)
>       {
> !       if (!lto_symtab_resolve_can_prevail_p (e)
> !       || !symtab_real_symbol_p (e))
>       continue;
>   
>         /* Choose the first function that can prevail as prevailing.  */
> --- 322,328 ----
>     /* Do a second round choosing one from the replaceable prevailing decls.  
> */
>     for (e = first; e; e = e->symbol.next_sharing_asm_name)
>       {
> !       if (!lto_symtab_resolve_can_prevail_p (e))
>       continue;
>   
>         /* Choose the first function that can prevail as prevailing.  */
> *************** lto_symtab_merge_decls_2 (symtab_node fi
> *** 365,375 ****
>     /* Try to merge each entry with the prevailing one.  */
>     for (e = prevailing->symbol.next_sharing_asm_name;
>          e; e = e->symbol.next_sharing_asm_name)
> !     {
> !       if (!lto_symtab_merge (prevailing, e)
> !       && !diagnosed_p)
> !     mismatches.safe_push (e->symbol.decl);
> !     }
>     if (mismatches.is_empty ())
>       return;
>   
> --- 376,387 ----
>     /* Try to merge each entry with the prevailing one.  */
>     for (e = prevailing->symbol.next_sharing_asm_name;
>          e; e = e->symbol.next_sharing_asm_name)
> !     if (TREE_PUBLIC (e->symbol.decl))
> !       {
> !     if (!lto_symtab_merge (prevailing, e)
> !         && !diagnosed_p)
> !       mismatches.safe_push (e->symbol.decl);
> !       }
>     if (mismatches.is_empty ())
>       return;
>   
> *************** lto_symtab_merge_decls_1 (symtab_node fi
> *** 411,417 ****
>         fprintf (cgraph_dump_file, "Merging nodes for %s. Candidates:\n",
>              symtab_node_asm_name (first));
>         for (e = first; e; e = e->symbol.next_sharing_asm_name)
> !     dump_symtab_node (cgraph_dump_file, e);
>       }
>   
>     /* Compute the symbol resolutions.  This is a no-op when using the
> --- 423,430 ----
>         fprintf (cgraph_dump_file, "Merging nodes for %s. Candidates:\n",
>              symtab_node_asm_name (first));
>         for (e = first; e; e = e->symbol.next_sharing_asm_name)
> !     if (TREE_PUBLIC (e->symbol.decl))
> !       dump_symtab_node (cgraph_dump_file, e);
>       }
>   
>     /* Compute the symbol resolutions.  This is a no-op when using the
> *************** lto_symtab_merge_decls_1 (symtab_node fi
> *** 436,442 ****
>         for (e = prevailing->symbol.next_sharing_asm_name;
>              e; e = e->symbol.next_sharing_asm_name)
>           if (!COMPLETE_TYPE_P (TREE_TYPE (prevailing->symbol.decl))
> !             && COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl)))
>             prevailing = e;
>       }
>         /* For variables prefer the non-builtin if one is available.  */
> --- 449,456 ----
>         for (e = prevailing->symbol.next_sharing_asm_name;
>              e; e = e->symbol.next_sharing_asm_name)
>           if (!COMPLETE_TYPE_P (TREE_TYPE (prevailing->symbol.decl))
> !             && COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl))
> !             && lto_symtab_symbol_p (e))
>             prevailing = e;
>       }
>         /* For variables prefer the non-builtin if one is available.  */
> *************** lto_symtab_merge_decls_1 (symtab_node fi
> *** 444,450 ****
>       {
>         for (e = first; e; e = e->symbol.next_sharing_asm_name)
>           if (TREE_CODE (e->symbol.decl) == FUNCTION_DECL
> !             && !DECL_BUILT_IN (e->symbol.decl))
>             {
>               prevailing = e;
>               break;
> --- 458,465 ----
>       {
>         for (e = first; e; e = e->symbol.next_sharing_asm_name)
>           if (TREE_CODE (e->symbol.decl) == FUNCTION_DECL
> !             && !DECL_BUILT_IN (e->symbol.decl)
> !             && lto_symtab_symbol_p (e))
>             {
>               prevailing = e;
>               break;
> *************** lto_symtab_merge_decls_1 (symtab_node fi
> *** 461,466 ****
> --- 476,483 ----
>         if (TREE_CODE (prevailing->symbol.decl)
>         == TREE_CODE (e->symbol.decl))
>       continue;
> +       if (!lto_symtab_symbol_p (e))
> +     continue;
>   
>         switch (TREE_CODE (prevailing->symbol.decl))
>       {
> *************** lto_symtab_merge_cgraph_nodes_1 (symtab_
> *** 530,536 ****
>       {
>         next = e->symbol.next_sharing_asm_name;
>   
> !       if (!symtab_real_symbol_p (e))
>       continue;
>         cgraph_node *ce = dyn_cast <cgraph_node> (e);
>         if (ce && !DECL_BUILT_IN (e->symbol.decl))
> --- 547,553 ----
>       {
>         next = e->symbol.next_sharing_asm_name;
>   
> !       if (!lto_symtab_symbol_p (e))
>       continue;
>         cgraph_node *ce = dyn_cast <cgraph_node> (e);
>         if (ce && !DECL_BUILT_IN (e->symbol.decl))
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend

Reply via email to