[PATCH] Fix for PR ipa/65245

Jan Hubicka hubicka@ucw.cz
Sun Mar 1 17:57:00 GMT 2015


> >From 7cedbe5e3736b9eb7b2fab1b931a7bc9ed269f37 Mon Sep 17 00:00:00 2001
> From: mliska <mliska@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  <mliska@suse.cz>
> 	    Jan Hubicka   <hubicka@ucw.cz>
> 
> 	* ipa-icf-gimple.c (func_checker::compare_function_decl):
> 	Consider ultimate alias as targets.
> 	* ipa-icf.c (sem_function::parse): Do not consider aliases.
> 	(sem_function::compare_cgraph_references): Consider ultimate
> 	alias as targets.
> 	(sem_variable::parse):  Likewise.
> 	(sem_item_optimizer::build_graph): Consider ultimate aliases
> 	for references.
> 
> gcc/testsuite/ChangeLog:
> 
> 2015-02-28  Martin Liska  <mliska@suse.cz>
> 	    Jan Hubicka   <hubicka@ucw.cz>
> 
> 	* gcc.dg/ipa/ipa-icf-34.c: New test.
> 	* gcc.target/i386/stackalign/longlong-2.c: Omit ICF.
> ---
>  gcc/ipa-icf-gimple.c                  |  4 ++--
>  gcc/ipa-icf.c                         | 14 +++++++++++---
>  gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c | 28 ++++++++++++++++++++++++++++
>  3 files changed, 41 insertions(+), 5 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-34.c
> 
> diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
> index cbeb795..8008e86 100644
> --- a/gcc/ipa-icf-gimple.c
> +++ b/gcc/ipa-icf-gimple.c
> @@ -543,8 +543,8 @@ func_checker::compare_function_decl (tree t1, tree t2)
>    if (t1 == t2)
>      return true;
>  
> -  symtab_node *n1 = symtab_node::get (t1);
> -  symtab_node *n2 = symtab_node::get (t2);
> +  symtab_node *n1 = symtab_node::get (t1)->ultimate_alias_target ();
> +  symtab_node *n2 = symtab_node::get (t2)->ultimate_alias_target ();

Do we really need to compare them here if they are already compared by equals_wpa?
The logic here is bit more difficult - it depends on alias if it is interposable
or not.  This is obtained by symtab_node::get (t1)->ultimate_alias_target (&avail);

if one of aliases is interposable, you want to use symtab_node::get
(t1)->equal_address_to (symtab_node::get (t2)) if address of given reference
matters and semantically_equivalent_p otherwise.

This is all done already in WPA checking, so I would suggest just assuming that
decl maps if both pass decl_in_symtab_p.
>  
>    if (m_ignored_source_nodes != NULL && m_ignored_target_nodes != NULL)
>      {
> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index 92133fc..b95db0d 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -342,6 +342,9 @@ sem_function::compare_cgraph_references (hash_map <symtab_node *, sem_item *>
>      &ignored_nodes,
>      symtab_node *n1, symtab_node *n2)
>  {
> +  n1 = n1->ultimate_alias_target ();
> +  n2 = n2->ultimate_alias_target ();
> +
>    if (n1 == n2 || (ignored_nodes.get (n1) && ignored_nodes.get (n2)))
>      return true;

Here I sent you correct change privately yesterday - you want to use equal_address_to.
I would still suggest just putting all those into sensitive reference lists.

Rest of the patch looks OK.
Honza



More information about the Gcc-patches mailing list