diff options
-rw-r--r-- | gcc/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/ipa-cp.c | 19 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 49 | ||||
-rw-r--r-- | gcc/ipa-prop.h | 12 |
4 files changed, 78 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e4e35d..f148201 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +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> PR target/44074 diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 723de16..f4aab5d 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -917,12 +917,9 @@ ipcp_update_callgraph (void) for (i = 0; i < count; 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. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (orig_node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) { bitmap_set_bit (args_to_skip, i); continue; @@ -995,12 +992,9 @@ ipcp_estimate_growth (struct cgraph_node *node) for (i = 0; i < count; 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. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) removable_args++; if (lat->type == IPA_CONST_VALUE) @@ -1068,12 +1062,9 @@ ipcp_const_param_count (struct cgraph_node *node) for (i = 0; i < count; i++) { struct ipcp_lattice *lat = ipcp_get_lattice (info, i); - tree parm_tree = ipa_get_param (info, i); if (ipcp_lat_is_insertable (lat) /* Do not count obviously unused arguments. */ - && (!is_gimple_reg (parm_tree) - || gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree))) + && ipa_is_param_used (info, i)) const_param++; } return const_param; @@ -1177,9 +1168,7 @@ ipcp_insert_stage (void) parm_tree = ipa_get_param (info, i); /* We can proactively remove obviously unused arguments. */ - if (is_gimple_reg (parm_tree) - && !gimple_default_def (DECL_STRUCT_FUNCTION (node->decl), - parm_tree)) + if (!ipa_is_param_used (info, i)) { bitmap_set_bit (args_to_skip, i); continue; diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index e66aab5..113a008 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -211,6 +211,29 @@ visit_store_addr_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED, int index = ipa_get_param_decl_index (info, op); gcc_assert (index >= 0); 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; @@ -229,14 +252,26 @@ ipa_detect_param_modifications (struct cgraph_node *node) struct function *func; gimple_stmt_iterator gsi; struct ipa_node_params *info = IPA_NODE_REF (node); + int i; if (ipa_get_param_count (info) == 0 || info->modification_analysis_done) 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); FOR_EACH_BB_FN (bb, func) 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); @@ -1747,6 +1782,8 @@ ipa_print_node_params (FILE * f, struct cgraph_node *node) : "(unnamed)")); if (ipa_is_param_modified (info, i)) fprintf (f, " modified"); + if (ipa_is_param_used (info, i)) + fprintf (f, " used"); fprintf (f, "\n"); } } @@ -2361,7 +2398,10 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node) gcc_assert (!info->node_enqueued); gcc_assert (!info->ipcp_orig_node); 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); bitpack_delete (bp); 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, } info->node_enqueued = false; 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); for (e = node->callees; e; e = e->next_callee) { diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 0f9b5f3..c142c03 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -163,6 +163,8 @@ struct ipa_param_descriptor tree decl; /* Whether the value parameter has been modified within the function. */ unsigned modified : 1; + /* The parameter is used. */ + unsigned used : 1; }; /* 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) 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. */ static inline void @@ -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_read_jump_functions (void); void ipa_update_after_lto_read (void); -void lto_ipa_fixup_call_notes (struct cgraph_node *, gimple *); /* From tree-sra.c: */ bool build_ref_for_offset (tree *, tree, HOST_WIDE_INT, tree, bool); |