> Hello.
> 
> Following patch skips all variable aliases as potential merge candidates. 
> Tested on x86_64-linux.
> 
> Ready for trunk?
> Thanks,
> Martin

> >From fbde2e98f98a71105d18cf3e91e8032d0c657139 Mon Sep 17 00:00:00 2001
> From: mliska <mli...@suse.cz>
> Date: Fri, 27 Feb 2015 22:42:49 +0100
> Subject: [PATCH 2/4] ICF: Do not consider variable aliases for merge
>  operation.
> 
> gcc/ChangeLog:
> 
> 2015-02-28  Martin Liska  <mli...@suse.cz>
>           Jan Hubicka   <hubi...@ucw.cz>
> 
>       PR ipa/65245
>       * ipa-icf.c (sem_function::parse): Do not consider aliases.
>       (sem_variable::parse):  Likewise.
>       (sem_item_optimizer::build_graph): Consider ultimate aliases
>       for references.

OK, can you please add a testcase checking that two functions get merged even
if each of them referrs different alias of an equvalent symbols?

Honza
> ---
>  gcc/ipa-icf.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index 92133fc..864a5d0 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -1095,7 +1095,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack 
> *stack)
>    tree fndecl = node->decl;
>    function *func = DECL_STRUCT_FUNCTION (fndecl);
>  
> -  /* TODO: add support for thunks and aliases.  */
> +  /* TODO: add support for thunks.  */
>  
>    if (!func || !node->has_gimple_body_p ())
>      return NULL;
> @@ -1407,6 +1407,9 @@ sem_variable::parse (varpool_node *node, bitmap_obstack 
> *stack)
>  {
>    tree decl = node->decl;
>  
> +  if (node->alias)
> +    return NULL;
> +
>    bool readonly = TYPE_P (decl) ? TYPE_READONLY (decl) : TREE_READONLY 
> (decl);
>    if (!readonly)
>      return NULL;
> @@ -2057,7 +2060,8 @@ sem_item_optimizer::build_graph (void)
>         cgraph_edge *e = cnode->callees;
>         while (e)
>           {
> -           sem_item **slot = m_symtab_node_map.get (e->callee);
> +           sem_item **slot = m_symtab_node_map.get
> +             (e->callee->ultimate_alias_target ());
>             if (slot)
>               item->add_reference (*slot);
>  
> @@ -2068,7 +2072,8 @@ sem_item_optimizer::build_graph (void)
>        ipa_ref *ref = NULL;
>        for (unsigned i = 0; item->node->iterate_reference (i, ref); i++)
>       {
> -       sem_item **slot = m_symtab_node_map.get (ref->referred);
> +       sem_item **slot = m_symtab_node_map.get
> +         (ref->referred->ultimate_alias_target ());
>         if (slot)
>           item->add_reference (*slot);
>       }
> -- 
> 2.1.2
> 

Reply via email to