Commit 339f49ec by Jan Hubicka Committed by Jan Hubicka

ipa-cp.c (ipcp_update_callgraph): Use ipa_is_param_used.


	* ipa-cp.c (ipcp_update_callgraph): Use ipa_is_param_used.
	(ipcp_estimate_growth): Likewise.
	(ipcp_const_param_count): Likewise.
	(ipcp_insert_stage): Likewise.
	* ipa-prop.c (visit_load_for_mod_analysis): New function.
	(visit_store_addr_for_mod_analysis): Set used flag.
	(ipa_detect_param_modifications): Set used flag for SSE params;
	update use of walk_stmt_load_store_addr_ops.
	(ipa_print_node_params): Print used flag.
	(ipa_write_node_info): Stream used flag.
	(ipa_read_node_info): Likewise.
	* ipa-prop.h (struct ipa_param_descriptor): Add used field.
	(ipa_is_param_used): New function.
	(lto_ipa_fixup_call_notes): Remove unused declaration.

From-SVN: r159513
parent 2433310d
2010-05-17 Jan Hubicka <jh@suse.cz>
* ipa-cp.c (ipcp_update_callgraph): Use ipa_is_param_used.
(ipcp_estimate_growth): Likewise.
(ipcp_const_param_count): Likewise.
(ipcp_insert_stage): Likewise.
* ipa-prop.c (visit_load_for_mod_analysis): New function.
(visit_store_addr_for_mod_analysis): Set used flag.
(ipa_detect_param_modifications): Set used flag for SSE params;
update use of walk_stmt_load_store_addr_ops.
(ipa_print_node_params): Print used flag.
(ipa_write_node_info): Stream used flag.
(ipa_read_node_info): Likewise.
* ipa-prop.h (struct ipa_param_descriptor): Add used field.
(ipa_is_param_used): New function.
(lto_ipa_fixup_call_notes): Remove unused declaration.
2010-05-17 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2010-05-17 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/44074 PR target/44074
......
...@@ -917,12 +917,9 @@ ipcp_update_callgraph (void) ...@@ -917,12 +917,9 @@ ipcp_update_callgraph (void)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
struct ipcp_lattice *lat = ipcp_get_lattice (info, i); struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
tree parm_tree = ipa_get_param (info, i);
/* We can proactively remove obviously unused arguments. */ /* We can proactively remove obviously unused arguments. */
if (is_gimple_reg (parm_tree) if (!ipa_is_param_used (info, i))
&& !gimple_default_def (DECL_STRUCT_FUNCTION (orig_node->decl),
parm_tree))
{ {
bitmap_set_bit (args_to_skip, i); bitmap_set_bit (args_to_skip, i);
continue; continue;
...@@ -995,12 +992,9 @@ ipcp_estimate_growth (struct cgraph_node *node) ...@@ -995,12 +992,9 @@ ipcp_estimate_growth (struct cgraph_node *node)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
struct ipcp_lattice *lat = ipcp_get_lattice (info, i); struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
tree parm_tree = ipa_get_param (info, i);
/* We can proactively remove obviously unused arguments. */ /* We can proactively remove obviously unused arguments. */
if (is_gimple_reg (parm_tree) if (!ipa_is_param_used (info, i))
&& !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl),
parm_tree))
removable_args++; removable_args++;
if (lat->type == IPA_CONST_VALUE) if (lat->type == IPA_CONST_VALUE)
...@@ -1068,12 +1062,9 @@ ipcp_const_param_count (struct cgraph_node *node) ...@@ -1068,12 +1062,9 @@ ipcp_const_param_count (struct cgraph_node *node)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
struct ipcp_lattice *lat = ipcp_get_lattice (info, i); struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
tree parm_tree = ipa_get_param (info, i);
if (ipcp_lat_is_insertable (lat) if (ipcp_lat_is_insertable (lat)
/* Do not count obviously unused arguments. */ /* Do not count obviously unused arguments. */
&& (!is_gimple_reg (parm_tree) && ipa_is_param_used (info, i))
|| gimple_default_def (DECL_STRUCT_FUNCTION (node->decl),
parm_tree)))
const_param++; const_param++;
} }
return const_param; return const_param;
...@@ -1177,9 +1168,7 @@ ipcp_insert_stage (void) ...@@ -1177,9 +1168,7 @@ ipcp_insert_stage (void)
parm_tree = ipa_get_param (info, i); parm_tree = ipa_get_param (info, i);
/* We can proactively remove obviously unused arguments. */ /* We can proactively remove obviously unused arguments. */
if (is_gimple_reg (parm_tree) if (!ipa_is_param_used (info, i))
&& !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl),
parm_tree))
{ {
bitmap_set_bit (args_to_skip, i); bitmap_set_bit (args_to_skip, i);
continue; continue;
......
...@@ -211,6 +211,29 @@ visit_store_addr_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED, ...@@ -211,6 +211,29 @@ visit_store_addr_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED,
int index = ipa_get_param_decl_index (info, op); int index = ipa_get_param_decl_index (info, op);
gcc_assert (index >= 0); gcc_assert (index >= 0);
info->params[index].modified = true; info->params[index].modified = true;
info->params[index].used = true;
}
return false;
}
/* Callback of walk_stmt_load_store_addr_ops for the visit_load.
If OP is a parameter declaration, mark it as used in the info structure
passed in DATA. */
static bool
visit_load_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED,
tree op, void *data)
{
struct ipa_node_params *info = (struct ipa_node_params *) data;
op = get_base_address (op);
if (op
&& TREE_CODE (op) == PARM_DECL)
{
int index = ipa_get_param_decl_index (info, op);
gcc_assert (index >= 0);
info->params[index].used = true;
} }
return false; return false;
...@@ -229,14 +252,26 @@ ipa_detect_param_modifications (struct cgraph_node *node) ...@@ -229,14 +252,26 @@ ipa_detect_param_modifications (struct cgraph_node *node)
struct function *func; struct function *func;
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
struct ipa_node_params *info = IPA_NODE_REF (node); struct ipa_node_params *info = IPA_NODE_REF (node);
int i;
if (ipa_get_param_count (info) == 0 || info->modification_analysis_done) if (ipa_get_param_count (info) == 0 || info->modification_analysis_done)
return; return;
for (i = 0; i < ipa_get_param_count (info); i++)
{
tree parm = ipa_get_param (info, i);
/* For SSA regs see if parameter is used. For non-SSA we compute
the flag during modification analysis. */
if (is_gimple_reg (parm)
&& gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), parm))
info->params[i].used = true;
}
func = DECL_STRUCT_FUNCTION (decl); func = DECL_STRUCT_FUNCTION (decl);
FOR_EACH_BB_FN (bb, func) FOR_EACH_BB_FN (bb, func)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
walk_stmt_load_store_addr_ops (gsi_stmt (gsi), info, NULL, walk_stmt_load_store_addr_ops (gsi_stmt (gsi), info,
visit_load_for_mod_analysis,
visit_store_addr_for_mod_analysis, visit_store_addr_for_mod_analysis,
visit_store_addr_for_mod_analysis); visit_store_addr_for_mod_analysis);
...@@ -1747,6 +1782,8 @@ ipa_print_node_params (FILE * f, struct cgraph_node *node) ...@@ -1747,6 +1782,8 @@ ipa_print_node_params (FILE * f, struct cgraph_node *node)
: "(unnamed)")); : "(unnamed)"));
if (ipa_is_param_modified (info, i)) if (ipa_is_param_modified (info, i))
fprintf (f, " modified"); fprintf (f, " modified");
if (ipa_is_param_used (info, i))
fprintf (f, " used");
fprintf (f, "\n"); fprintf (f, "\n");
} }
} }
...@@ -2361,7 +2398,10 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node) ...@@ -2361,7 +2398,10 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node)
gcc_assert (!info->node_enqueued); gcc_assert (!info->node_enqueued);
gcc_assert (!info->ipcp_orig_node); gcc_assert (!info->ipcp_orig_node);
for (j = 0; j < ipa_get_param_count (info); j++) for (j = 0; j < ipa_get_param_count (info); j++)
bp_pack_value (bp, info->params[j].modified, 1); {
bp_pack_value (bp, info->params[j].modified, 1);
bp_pack_value (bp, info->params[j].used, 1);
}
lto_output_bitpack (ob->main_stream, bp); lto_output_bitpack (ob->main_stream, bp);
bitpack_delete (bp); bitpack_delete (bp);
for (e = node->callees; e; e = e->next_callee) for (e = node->callees; e; e = e->next_callee)
...@@ -2400,7 +2440,10 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node, ...@@ -2400,7 +2440,10 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node,
} }
info->node_enqueued = false; info->node_enqueued = false;
for (k = 0; k < ipa_get_param_count (info); k++) for (k = 0; k < ipa_get_param_count (info); k++)
info->params[k].modified = bp_unpack_value (bp, 1); {
info->params[k].modified = bp_unpack_value (bp, 1);
info->params[k].used = bp_unpack_value (bp, 1);
}
bitpack_delete (bp); bitpack_delete (bp);
for (e = node->callees; e; e = e->next_callee) for (e = node->callees; e; e = e->next_callee)
{ {
......
...@@ -163,6 +163,8 @@ struct ipa_param_descriptor ...@@ -163,6 +163,8 @@ struct ipa_param_descriptor
tree decl; tree decl;
/* Whether the value parameter has been modified within the function. */ /* Whether the value parameter has been modified within the function. */
unsigned modified : 1; unsigned modified : 1;
/* The parameter is used. */
unsigned used : 1;
}; };
/* ipa_node_params stores information related to formal parameters of functions /* ipa_node_params stores information related to formal parameters of functions
...@@ -237,6 +239,15 @@ ipa_is_param_modified (struct ipa_node_params *info, int i) ...@@ -237,6 +239,15 @@ ipa_is_param_modified (struct ipa_node_params *info, int i)
return info->params[i].modified; return info->params[i].modified;
} }
/* Return the used flag corresponding to the Ith formal parameter of
the function associated with INFO. */
static inline bool
ipa_is_param_used (struct ipa_node_params *info, int i)
{
return info->params[i].used;
}
/* Flag this node as having callers with variable number of arguments. */ /* Flag this node as having callers with variable number of arguments. */
static inline void static inline void
...@@ -489,7 +500,6 @@ void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree); ...@@ -489,7 +500,6 @@ void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree);
void ipa_prop_write_jump_functions (cgraph_node_set set); void ipa_prop_write_jump_functions (cgraph_node_set set);
void ipa_prop_read_jump_functions (void); void ipa_prop_read_jump_functions (void);
void ipa_update_after_lto_read (void); void ipa_update_after_lto_read (void);
void lto_ipa_fixup_call_notes (struct cgraph_node *, gimple *);
/* From tree-sra.c: */ /* From tree-sra.c: */
bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool); bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool);
......
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