> Only differences in v2 are in symbol_table::remove_unreachable_nodes,
> see comment below.
> 
> ---
> 
> ref_by_asm will be used by toplevel assembly to mark symbols that cannot
> be removed.
> It largely overlaps with force_output. Main difference is that ref_by_asm
> is meaningful on declarations by not removing them. force_output with
> declaration is ignored, which cannot be easily changed, since several
> places depend on this behavior.

What places depends on this?
> 
> Global ref_by_asm should not be localized, because they cannot benefit
> from it. It would only result in complications, for example by renaming
> the symbol.
> 
> Notes on different solutions in unreachability analysis:
> First unreachability analysis is done in analyze_functions. Marking
> ref_by_asm declarations as needed from the start would require
> reprocessing, because some declarations may gain definition during the
> analysis. Since at this point declarations do not need adding any other
> symbol, we can check for ref_by_asm at the end, next to referred_to_p
> check.
> 
> Second unreachability analysis is in remove_unreachable_nodes. Here
> declarations (or symbols in_other_partition) may require an alias.
> So there we need to add the declarations from the start.
> 
> gcc/ChangeLog:
> 
>       * cgraph.cc (cgraph_node_cannot_be_local_p_1): Check ref_by_asm.
>       (cgraph_node::verify_node): Likewise.
>       * cgraph.h (cgraph_node::only_called_directly_or_aliased_p):
>       Likewise.
>       (cgraph_node::can_remove_if_no_direct_calls_and_refs_p):
>       Likewise.
>       (varpool_node::can_remove_if_no_refs_p): Likewise.
>       (varpool_node::all_refs_explicit_p): Likewise.
>       * cgraphunit.cc (symtab_node::needed_p): Likewise.
>       (analyze_functions): Likewise.
>       * gimple-ssa-pta-constraints.cc (refered_from_nonlocal_fn):
>       Likewise.
>       (refered_from_nonlocal_var): Likewise.
>       (ipa_create_global_variable_infos): Likewise.
>       * ipa-comdats.cc (ipa_comdats): Likewise.
>       * ipa-visibility.cc (cgraph_externally_visible_p): Likewise.
>       (varpool_node::externally_visible_p): Likewise.
>       * ipa.cc (symbol_table::remove_unreachable_nodes): Likewise.
>       * lto-cgraph.cc (lto_output_node): Output ref_by_asm.
>       (lto_output_varpool_node): Likewise.
>       (input_overwrite_node): Input ref_by_asm.
>       (input_varpool_node): Likewise.
>       * symtab.cc (address_matters_1): Check ref_by_asm.
> 
> gcc/lto/ChangeLog:
> 
>       * lto-symtab.cc (lto_cgraph_replace_node): Propagate ref_by_asm.
>       (lto_varpool_replace_node): Propagate ref_by_asm.

This is OK.  I think references from asm statement are reasonably
special to have its own flag...

Honza

Reply via email to