summaryrefslogtreecommitdiff
path: root/gcc/ipa-prop.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2019-09-20 00:25:04 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2019-09-20 00:25:04 +0200
commitff6686d2e5f797d6c6a36ad14a7084bc1dc350e4 (patch)
tree21de4e26dd766dab8b60b2be7190a6b86bad2b38 /gcc/ipa-prop.c
parent6889a3acfeed47265886676c6d43b04ef799fb82 (diff)
New IPA-SRA
2019-09-20 Martin Jambor <mjambor@suse.cz> * coretypes.h (cgraph_edge): Declare. * ipa-param-manipulation.c: Rewrite. * ipa-param-manipulation.h: Likewise. * Makefile.in (GTFILES): Added ipa-param-manipulation.h and ipa-sra.c. (OBJS): Added ipa-sra.o. * cgraph.h (ipa_replace_map): Removed fields old_tree, replace_p and ref_p, added fields param_adjustments and performed_splits. (struct cgraph_clone_info): Remove ags_to_skip and combined_args_to_skip, new field param_adjustments. (cgraph_node::create_clone): Changed parameters to use ipa_param_adjustments. (cgraph_node::create_virtual_clone): Likewise. (cgraph_node::create_virtual_clone_with_body): Likewise. (tree_function_versioning): Likewise. (cgraph_build_function_type_skip_args): Removed. * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Convert to using ipa_param_adjustments. (clone_of_p): Likewise. * cgraphclones.c (cgraph_build_function_type_skip_args): Removed. (build_function_decl_skip_args): Likewise. (duplicate_thunk_for_node): Adjust parameters using ipa_param_body_adjustments, copy param_adjustments instead of args_to_skip. (cgraph_node::create_clone): Convert to using ipa_param_adjustments. (cgraph_node::create_virtual_clone): Likewise. (cgraph_node::create_version_clone_with_body): Likewise. (cgraph_materialize_clone): Likewise. (symbol_table::materialize_all_clones): Likewise. * ipa-fnsummary.c (ipa_fn_summary_t::duplicate): Simplify ipa_replace_map check. * ipa-cp.c (get_replacement_map): Do not initialize removed fields. (initialize_node_lattices): Make aware that some parameters might have already been removed. (want_remove_some_param_p): New function. (create_specialized_node): Convert to using ipa_param_adjustments and deal with possibly pre-existing adjustments. * lto-cgraph.c (output_cgraph_opt_summary_p): Likewise. (output_node_opt_summary): Do not stream removed fields. Stream parameter adjustments instead of argumetns to skip. (input_node_opt_summary): Likewise. (input_node_opt_summary): Likewise. * lto-section-in.c (lto_section_name): Added ipa-sra section. * lto-streamer.h (lto_section_type): Likewise. * tree-inline.h (copy_body_data): New fields killed_new_ssa_names and param_body_adjs. (copy_decl_to_var): Declare. * tree-inline.c (update_clone_info): Do not remap old_tree. (remap_gimple_stmt): Use ipa_param_body_adjustments to modify gimple statements, walk all extra generated statements and remap their operands. (redirect_all_calls): Add killed SSA names to a hash set. (remap_ssa_name): Do not remap killed SSA names. (copy_arguments_for_versioning): Renames to copy_arguments_nochange, half of functionality moved to ipa_param_body_adjustments. (copy_decl_to_var): Make exported. (copy_body): Destroy killed_new_ssa_names hash set. (expand_call_inline): Remap performed splits. (update_clone_info): Likewise. (tree_function_versioning): Simplify tree_map processing. Updated to accept ipa_param_adjustments and use ipa_param_body_adjustments. * omp-simd-clone.c (simd_clone_vector_of_formal_parm_types): Adjust for the new interface. (simd_clone_clauses_extract): Likewise, make args an auto_vec. (simd_clone_compute_base_data_type): Likewise. (simd_clone_init_simd_arrays): Adjust for the new interface. (simd_clone_adjust_argument_types): Likewise. (struct modify_stmt_info): Likewise. (ipa_simd_modify_stmt_ops): Likewise. (ipa_simd_modify_function_body): Likewise. (simd_clone_adjust): Likewise. * tree-sra.c: Removed IPA-SRA. Include tree-sra.h. (type_internals_preclude_sra_p): Make public. * tree-sra.h: New file. * ipa-inline-transform.c (save_inline_function_body): Update to refelct new tree_function_versioning signature. * ipa-prop.c (adjust_agg_replacement_values): Use a helper from ipa_param_adjustments to get current parameter indices. (ipcp_modif_dom_walker::before_dom_children): Likewise. (ipcp_update_bits): Likewise. (ipcp_update_vr): Likewise. * ipa-split.c (split_function): Convert to using ipa_param_adjustments. * ipa-sra.c: New file. * multiple_target.c (create_target_clone): Update to reflet new type of create_version_clone_with_body. * trans-mem.c (ipa_tm_create_version): Update to reflect new type of tree_function_versioning. (modify_function): Update to reflect new type of tree_function_versioning. * params.def (PARAM_IPA_SRA_MAX_REPLACEMENTS): New. * passes.def: Remove old IPA-SRA and add new one. * tree-pass.h (make_pass_early_ipa_sra): Remove declaration. (make_pass_ipa_sra): Declare. * dbgcnt.def: Remove eipa_sra. Added ipa_sra_params and ipa_sra_retvalues. * doc/invoke.texi (ipa-sra-max-replacements): New. testsuite/ * g++.dg/ipa/pr81248.C: Adjust dg-options and dump-scan. * gcc.dg/ipa/ipa-sra-1.c: Likewise. * gcc.dg/ipa/ipa-sra-10.c: Likewise. * gcc.dg/ipa/ipa-sra-11.c: Likewise. * gcc.dg/ipa/ipa-sra-3.c: Likewise. * gcc.dg/ipa/ipa-sra-4.c: Likewise. * gcc.dg/ipa/ipa-sra-5.c: Likewise. * gcc.dg/ipa/ipacost-2.c: Disable ipa-sra. * gcc.dg/ipa/ipcp-agg-9.c: Likewise. * gcc.dg/ipa/pr78121.c: Adjust scan pattern. * gcc.dg/ipa/vrp1.c: Likewise. * gcc.dg/ipa/vrp2.c: Likewise. * gcc.dg/ipa/vrp3.c: Likewise. * gcc.dg/ipa/vrp7.c: Likewise. * gcc.dg/ipa/vrp8.c: Likewise. * gcc.dg/noreorder.c: use noipa attribute instead of noinline. * gcc.dg/ipa/20040703-wpa.c: New test. * gcc.dg/ipa/ipa-sra-12.c: New test. * gcc.dg/ipa/ipa-sra-13.c: Likewise. * gcc.dg/ipa/ipa-sra-14.c: Likewise. * gcc.dg/ipa/ipa-sra-15.c: Likewise. * gcc.dg/ipa/ipa-sra-16.c: Likewise. * gcc.dg/ipa/ipa-sra-17.c: Likewise. * gcc.dg/ipa/ipa-sra-18.c: Likewise. * gcc.dg/ipa/ipa-sra-19.c: Likewise. * gcc.dg/ipa/ipa-sra-20.c: Likewise. * gcc.dg/ipa/ipa-sra-21.c: Likewise. * gcc.dg/ipa/ipa-sra-22.c: Likewise. * gcc.dg/sso/ipa-sra-1.c: Likewise. * g++.dg/ipa/ipa-sra-2.C: Likewise. * g++.dg/ipa/ipa-sra-3.C: Likewise. * gcc.dg/tree-ssa/ipa-cp-1.c: Make return value used. * g++.dg/ipa/devirt-19.C: Add missing return, add -fipa-cp-clone option. * g++.dg/lto/devirt-19_0.C: Add -fipa-cp-clone option. * gcc.dg/ipa/ipa-sra-2.c: Removed. * gcc.dg/ipa/ipa-sra-6.c: Likewise. From-SVN: r275982
Diffstat (limited to 'gcc/ipa-prop.c')
-rw-r--r--gcc/ipa-prop.c103
1 files changed, 67 insertions, 36 deletions
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index a23aa2590a0..2f2b0708cab 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -4851,31 +4851,24 @@ adjust_agg_replacement_values (struct cgraph_node *node,
struct ipa_agg_replacement_value *aggval)
{
struct ipa_agg_replacement_value *v;
- int i, c = 0, d = 0, *adj;
- if (!node->clone.combined_args_to_skip)
+ if (!node->clone.param_adjustments)
return;
+ auto_vec<int, 16> new_indices;
+ node->clone.param_adjustments->get_updated_indices (&new_indices);
for (v = aggval; v; v = v->next)
{
- gcc_assert (v->index >= 0);
- if (c < v->index)
- c = v->index;
- }
- c++;
-
- adj = XALLOCAVEC (int, c);
- for (i = 0; i < c; i++)
- if (bitmap_bit_p (node->clone.combined_args_to_skip, i))
- {
- adj[i] = -1;
- d++;
- }
- else
- adj[i] = i - d;
+ gcc_checking_assert (v->index >= 0);
- for (v = aggval; v; v = v->next)
- v->index = adj[v->index];
+ if ((unsigned) v->index < new_indices.length ())
+ v->index = new_indices[v->index];
+ else
+ /* This can happen if we know about a constant passed by reference by
+ an argument which is never actually used for anything, let alone
+ loading that constant. */
+ v->index = -1;
+ }
}
/* Dominator walker driving the ipcp modification phase. */
@@ -5001,24 +4994,41 @@ ipcp_modif_dom_walker::before_dom_children (basic_block bb)
static void
ipcp_update_bits (struct cgraph_node *node)
{
- tree parm = DECL_ARGUMENTS (node->decl);
- tree next_parm = parm;
ipcp_transformation *ts = ipcp_get_transformation_summary (node);
if (!ts || vec_safe_length (ts->bits) == 0)
return;
-
vec<ipa_bits *, va_gc> &bits = *ts->bits;
unsigned count = bits.length ();
+ if (!count)
+ return;
- for (unsigned i = 0; i < count; ++i, parm = next_parm)
+ auto_vec<int, 16> new_indices;
+ bool need_remapping = false;
+ if (node->clone.param_adjustments)
{
- if (node->clone.combined_args_to_skip
- && bitmap_bit_p (node->clone.combined_args_to_skip, i))
- continue;
+ node->clone.param_adjustments->get_updated_indices (&new_indices);
+ need_remapping = true;
+ }
+ auto_vec <tree, 16> parm_decls;
+ push_function_arg_decls (&parm_decls, node->decl);
+ for (unsigned i = 0; i < count; ++i)
+ {
+ tree parm;
+ if (need_remapping)
+ {
+ if (i >= new_indices.length ())
+ continue;
+ int idx = new_indices[i];
+ if (idx < 0)
+ continue;
+ parm = parm_decls[idx];
+ }
+ else
+ parm = parm_decls[i];
gcc_checking_assert (parm);
- next_parm = DECL_CHAIN (parm);
+
if (!bits[i]
|| !(INTEGRAL_TYPE_P (TREE_TYPE (parm))
@@ -5093,22 +5103,42 @@ ipcp_update_bits (struct cgraph_node *node)
static void
ipcp_update_vr (struct cgraph_node *node)
{
- tree fndecl = node->decl;
- tree parm = DECL_ARGUMENTS (fndecl);
- tree next_parm = parm;
ipcp_transformation *ts = ipcp_get_transformation_summary (node);
if (!ts || vec_safe_length (ts->m_vr) == 0)
return;
const vec<ipa_vr, va_gc> &vr = *ts->m_vr;
unsigned count = vr.length ();
+ if (!count)
+ return;
- for (unsigned i = 0; i < count; ++i, parm = next_parm)
+ auto_vec<int, 16> new_indices;
+ bool need_remapping = false;
+ if (node->clone.param_adjustments)
{
- if (node->clone.combined_args_to_skip
- && bitmap_bit_p (node->clone.combined_args_to_skip, i))
- continue;
+ node->clone.param_adjustments->get_updated_indices (&new_indices);
+ need_remapping = true;
+ }
+ auto_vec <tree, 16> parm_decls;
+ push_function_arg_decls (&parm_decls, node->decl);
+
+ for (unsigned i = 0; i < count; ++i)
+ {
+ tree parm;
+ int remapped_idx;
+ if (need_remapping)
+ {
+ if (i >= new_indices.length ())
+ continue;
+ remapped_idx = new_indices[i];
+ if (remapped_idx < 0)
+ continue;
+ }
+ else
+ remapped_idx = i;
+
+ parm = parm_decls[remapped_idx];
+
gcc_checking_assert (parm);
- next_parm = DECL_CHAIN (parm);
tree ddef = ssa_default_def (DECL_STRUCT_FUNCTION (node->decl), parm);
if (!ddef || !is_gimple_reg (parm))
@@ -5123,7 +5153,8 @@ ipcp_update_vr (struct cgraph_node *node)
{
if (dump_file)
{
- fprintf (dump_file, "Setting value range of param %u ", i);
+ fprintf (dump_file, "Setting value range of param %u "
+ "(now %i) ", i, remapped_idx);
fprintf (dump_file, "%s[",
(vr[i].type == VR_ANTI_RANGE) ? "~" : "");
print_decs (vr[i].min, dump_file);