Commit 2d8d3ae2 by Martin Liska Committed by Martin Liska

Fix IPA CP where it forgot to add a reference in cgraph (PR ipa/71190).

2017-01-20  Martin Liska  <mliska@suse.cz>

	PR ipa/71190
	* cgraph.h (maybe_create_reference): Remove argument and
	update comment.
	* cgraphclones.c (cgraph_node::create_virtual_clone): Remove one
	argument.
	* ipa-cp.c (create_specialized_node): Likewise.
	* symtab.c (symtab_node::maybe_create_reference): Handle
	VAR_DECLs and ADDR_EXPRs and select ipa_ref_use type.

From-SVN: r244687
parent a809d564
2017-01-20 Martin Liska <mliska@suse.cz> 2017-01-20 Martin Liska <mliska@suse.cz>
PR ipa/71190
* cgraph.h (maybe_create_reference): Remove argument and
update comment.
* cgraphclones.c (cgraph_node::create_virtual_clone): Remove one
argument.
* ipa-cp.c (create_specialized_node): Likewise.
* symtab.c (symtab_node::maybe_create_reference): Handle
VAR_DECLs and ADDR_EXPRs and select ipa_ref_use type.
2017-01-20 Martin Liska <mliska@suse.cz>
* read-rtl-function.c (function_reader::create_function): Use * read-rtl-function.c (function_reader::create_function): Use
build_decl instread of build_decl_stat. build_decl instread of build_decl_stat.
......
...@@ -131,11 +131,9 @@ public: ...@@ -131,11 +131,9 @@ public:
enum ipa_ref_use use_type, gimple *stmt); enum ipa_ref_use use_type, gimple *stmt);
/* If VAL is a reference to a function or a variable, add a reference from /* If VAL is a reference to a function or a variable, add a reference from
this symtab_node to the corresponding symbol table node. USE_TYPE specify this symtab_node to the corresponding symbol table node. Return the new
type of the use and STMT the statement (if it exists). Return the new
reference or NULL if none was created. */ reference or NULL if none was created. */
ipa_ref *maybe_create_reference (tree val, enum ipa_ref_use use_type, ipa_ref *maybe_create_reference (tree val, gimple *stmt);
gimple *stmt);
/* Clone all references from symtab NODE to this symtab_node. */ /* Clone all references from symtab NODE to this symtab_node. */
void clone_references (symtab_node *node); void clone_references (symtab_node *node);
......
...@@ -624,7 +624,7 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers, ...@@ -624,7 +624,7 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
|| in_lto_p) || in_lto_p)
new_node->unique_name = true; new_node->unique_name = true;
FOR_EACH_VEC_SAFE_ELT (tree_map, i, map) FOR_EACH_VEC_SAFE_ELT (tree_map, i, map)
new_node->maybe_create_reference (map->new_tree, IPA_REF_ADDR, NULL); new_node->maybe_create_reference (map->new_tree, NULL);
if (ipa_transforms_to_apply.exists ()) if (ipa_transforms_to_apply.exists ())
new_node->ipa_transforms_to_apply new_node->ipa_transforms_to_apply
......
...@@ -3786,7 +3786,7 @@ create_specialized_node (struct cgraph_node *node, ...@@ -3786,7 +3786,7 @@ create_specialized_node (struct cgraph_node *node,
args_to_skip, "constprop"); args_to_skip, "constprop");
ipa_set_node_agg_value_chain (new_node, aggvals); ipa_set_node_agg_value_chain (new_node, aggvals);
for (av = aggvals; av; av = av->next) for (av = aggvals; av; av = av->next)
new_node->maybe_create_reference (av->value, IPA_REF_ADDR, NULL); new_node->maybe_create_reference (av->value, NULL);
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
......
...@@ -588,18 +588,25 @@ symtab_node::create_reference (symtab_node *referred_node, ...@@ -588,18 +588,25 @@ symtab_node::create_reference (symtab_node *referred_node,
return ref; return ref;
} }
/* If VAL is a reference to a function or a variable, add a reference from
this symtab_node to the corresponding symbol table node. USE_TYPE specify
type of the use and STMT the statement (if it exists). Return the new
reference or NULL if none was created. */
ipa_ref * ipa_ref *
symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type, symtab_node::maybe_create_reference (tree val, gimple *stmt)
gimple *stmt)
{ {
STRIP_NOPS (val); STRIP_NOPS (val);
if (TREE_CODE (val) != ADDR_EXPR) ipa_ref_use use_type;
return NULL;
switch (TREE_CODE (val))
{
case VAR_DECL:
use_type = IPA_REF_LOAD;
break;
case ADDR_EXPR:
use_type = IPA_REF_ADDR;
break;
default:
gcc_assert (!handled_component_p (val));
return NULL;
}
val = get_base_var (val); val = get_base_var (val);
if (val && VAR_OR_FUNCTION_DECL_P (val)) if (val && VAR_OR_FUNCTION_DECL_P (val))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment