diff mbox

Fix IPA CP where it forgot to add a reference in cgraph

Message ID 87b66126-34a7-4935-d078-a14d979b3c9a@suse.cz
State New
Headers show

Commit Message

Martin Liška Dec. 20, 2016, 2:55 p.m. UTC
On 12/20/2016 11:06 AM, Martin Jambor wrote:
> ...this test should be for ADDR_EXPR here.  Or you could switch the
> IPA_REF_* constants the other way round which I bet is going to have
> the same effect in practice, but personally, I'd test for ADDR_EXPR.

Thanks for the note, fixed (and tested in second version of the patch).

Martin

> 
> Thanks,
> 
> Martin

Comments

Martin Liška Jan. 10, 2017, 10:49 a.m. UTC | #1
PING^1

On 12/20/2016 03:55 PM, Martin Liška wrote:
> On 12/20/2016 11:06 AM, Martin Jambor wrote:
>> ...this test should be for ADDR_EXPR here.  Or you could switch the
>> IPA_REF_* constants the other way round which I bet is going to have
>> the same effect in practice, but personally, I'd test for ADDR_EXPR.
>
> Thanks for the note, fixed (and tested in second version of the patch).
>
> Martin
>
>>
>> Thanks,
>>
>> Martin
>
Jan Hubicka Jan. 18, 2017, 10:18 p.m. UTC | #2
> 
> 2016-12-19  Martin Liska  <mliska@suse.cz>
> 
> 	* cgraphclones.c (cgraph_node::create_virtual_clone):
> 	Create either IPA_REF_LOAD of IPA_REF_READ depending on
> 	whether new_tree is a VAR_DECL or an ADDR_EXPR.
> 	* ipa-cp.c (create_specialized_node): Add reference just for
> 	ADDR_EXPRs.
> 	* symtab.c (symtab_node::maybe_create_reference): Remove guard
> 	as it's guarded in callers.
> ---
>  gcc/cgraphclones.c | 6 +++++-
>  gcc/ipa-cp.c       | 3 ++-
>  gcc/symtab.c       | 2 --
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
> index 349892dab67..6c8fe156f23 100644
> --- a/gcc/cgraphclones.c
> +++ b/gcc/cgraphclones.c
> @@ -624,7 +624,11 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
>        || in_lto_p)
>      new_node->unique_name = true;
>    FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
> -    new_node->maybe_create_reference (map->new_tree, IPA_REF_ADDR, NULL);
> +    {
> +      ipa_ref_use use_type
> +	= TREE_CODE (map->new_tree) == ADDR_EXPR ? IPA_REF_ADDR : IPA_REF_LOAD;
> +      new_node->maybe_create_reference (map->new_tree, use_type, NULL);
> +    }
>  
>    if (ipa_transforms_to_apply.exists ())
>      new_node->ipa_transforms_to_apply
> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index d3b50524457..fd312b56fde 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -3787,7 +3787,8 @@ create_specialized_node (struct cgraph_node *node,
>  					 args_to_skip, "constprop");
>    ipa_set_node_agg_value_chain (new_node, aggvals);
>    for (av = aggvals; av; av = av->next)
> -    new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL);
> +    if (TREE_CODE (av->value) == ADDR_EXPR)
> +      new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL);
>  
>    if (dump_file && (dump_flags & TDF_DETAILS))
>      {
> diff --git a/gcc/symtab.c b/gcc/symtab.c
> index 73168a8db09..562a4a2f6a6 100644
> --- a/gcc/symtab.c
> +++ b/gcc/symtab.c
> @@ -598,8 +598,6 @@ symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type,
>  				     gimple *stmt)
>  {
>    STRIP_NOPS (val);
> -  if (TREE_CODE (val) != ADDR_EXPR)
> -    return NULL;

Perhaps maybe_create_reference should drop the use_type argument (it is used
with IPA_REF_ADDR only anyway) and should do the parsing itself?
I.e. if there is reference do IPA_REF_LOAD and if there is ADDR_EXPR do
IPA_REF_ADDR.  Why one can not have handled component refs in there?

Honza
>    val = get_base_var (val);
>    if (val && VAR_OR_FUNCTION_DECL_P (val))
>      {
> -- 
> 2.11.0
>
diff mbox

Patch

From 2e29080e44cce899f9d5181185aba0a8a8791a9a Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 19 Dec 2016 11:03:34 +0100
Subject: [PATCH] Fix IPA CP where it forgot to add a reference in cgraph

gcc/ChangeLog:

2016-12-19  Martin Liska  <mliska@suse.cz>

	* cgraphclones.c (cgraph_node::create_virtual_clone):
	Create either IPA_REF_LOAD of IPA_REF_READ depending on
	whether new_tree is a VAR_DECL or an ADDR_EXPR.
	* ipa-cp.c (create_specialized_node): Add reference just for
	ADDR_EXPRs.
	* symtab.c (symtab_node::maybe_create_reference): Remove guard
	as it's guarded in callers.
---
 gcc/cgraphclones.c | 6 +++++-
 gcc/ipa-cp.c       | 3 ++-
 gcc/symtab.c       | 2 --
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 349892dab67..6c8fe156f23 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -624,7 +624,11 @@  cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
       || in_lto_p)
     new_node->unique_name = true;
   FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
-    new_node->maybe_create_reference (map->new_tree, IPA_REF_ADDR, NULL);
+    {
+      ipa_ref_use use_type
+	= TREE_CODE (map->new_tree) == ADDR_EXPR ? IPA_REF_ADDR : IPA_REF_LOAD;
+      new_node->maybe_create_reference (map->new_tree, use_type, NULL);
+    }
 
   if (ipa_transforms_to_apply.exists ())
     new_node->ipa_transforms_to_apply
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index d3b50524457..fd312b56fde 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -3787,7 +3787,8 @@  create_specialized_node (struct cgraph_node *node,
 					 args_to_skip, "constprop");
   ipa_set_node_agg_value_chain (new_node, aggvals);
   for (av = aggvals; av; av = av->next)
-    new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL);
+    if (TREE_CODE (av->value) == ADDR_EXPR)
+      new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 73168a8db09..562a4a2f6a6 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -598,8 +598,6 @@  symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type,
 				     gimple *stmt)
 {
   STRIP_NOPS (val);
-  if (TREE_CODE (val) != ADDR_EXPR)
-    return NULL;
   val = get_base_var (val);
   if (val && VAR_OR_FUNCTION_DECL_P (val))
     {
-- 
2.11.0