> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index 864a5d0..5b1fcff 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -1410,10 +1410,6 @@ sem_variable::parse (varpool_node *node, 
> bitmap_obstack *stack)
>    if (node->alias)
>      return NULL;
>  
> -  bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY 
> (decl);
> -  if (!readonly)
> -    return NULL;
> -
>    bool can_handle = DECL_VIRTUAL_P (decl)
>                   || flag_merge_constants >= 2
>                   || (!TREE_ADDRESSABLE (decl) && !node->externally_visible);

Please also drop can_handle and DECL_EXTERNAL check here.

can_handle seems to test if address matters. We already verify it at merging 
time
and at a time we consider REF_ADDR references. This is enough.
Moreover TREE_ADDRESSABLE and externally_visible flags are subject to change in 
between
analysis and WPA time.

Instead of this punt if THIS_VOLATILE is true.

Instead of ctor_for_folding bellow use DECL_INITIAL (ctor_for_folding may return
you NULL if it thinks the var is not safe)

> @@ -1900,7 +1896,14 @@ sem_item_optimizer::filter_removed_items (void)
>         if (!flag_ipa_icf_variables)
>           remove_item (item);
>         else
> -         filtered.safe_push (item);
> +         {
> +           /* Filter out non-readonly variables.  */
> +           tree decl = item->decl;
> +           if (TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY (decl))

Just test TREE_READONLY (decl).

OK with these changes.
Honza

Reply via email to