> I was playing around with this a few months ago but set it aside
> because we weren't in stage 1 at the time.  The way we currently set
> up comdat groups early means that we need to mangle decls early,
> significantly negating the earlier work to lazily set
> DECL_ASSEMBLER_NAME.  This patch improves this situation by allowing
> a DECL to be used as DECL_COMDAT_GROUP in cases where the group name
> is the same as the mangled name of the declaration.
> 
> Tested x86_64-pc-linux-gnu.  OK for trunk?

> commit 6f9182ed91a88bb993fe137f6decc15b25f466fd
> Author: Jason Merrill <ja...@redhat.com>
> Date:   Mon May 19 15:41:24 2014 -0400
> 
>       PR c++/47202
>     gcc/cp/
>       * decl.c (cxx_comdat_group): Return a decl.
>       * optimize.c (cdtor_comdat_group): Get its DECL_ASSEMBLER_NAME.
>     gcc/
>       * cgraphunit.c (analyze_functions): Convert all DECL_COMDAT_GROUPs
>       to IDENTIFIER_NODEs.
>       * tree.h (DECL_COMDAT_GROUP_ID): New.
>       * lto-streamer-out.c (write_symbol): Use it.
>       * symtab.c (dump_symtab_node): Likewise.
>       * trans-mem.c (ipa_tm_create_version_alias): Likewise.
> 
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index f5d9594..044af45 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -943,6 +943,14 @@ analyze_functions (void)
>    cgraph_state = CGRAPH_STATE_CONSTRUCTION;
>    input_location = UNKNOWN_LOCATION;
>  
> +  /* Convert all COMDAT group designators to IDENTIFIER_NODEs while we still
> +     have front end information.  */
> +  FOR_EACH_SYMBOL (node)
> +    if (DECL_COMDAT_GROUP (node->decl)
> +     && DECL_P (DECL_COMDAT_GROUP (node->decl)))
> +      DECL_COMDAT_GROUP (node->decl)
> +     = DECL_ASSEMBLER_NAME (DECL_COMDAT_GROUP (node->decl));A

Instead of adding extra loop over whole symtab, what about converting them at a 
time
the symbols are inserted into the symbol table or in 
function_and_variable_visibility
that already does quite few changes into various flags?

Honza

Reply via email to