This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] ICF: move readonly decision for variables to the right place
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Martin Liška <mliska at suse dot cz>
- Cc: "gcc-pat >> GCC Patches" <gcc-patches at gcc dot gnu dot org>, "hubicka >> Jan Hubicka" <hubicka at ucw dot cz>
- Date: Sun, 1 Mar 2015 01:26:35 +0100
- Subject: Re: [PATCH] ICF: move readonly decision for variables to the right place
- Authentication-results: sourceware.org; auth=none
- References: <54F25A19 dot 10903 at suse dot cz>
> 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