From 5af56ae8f839480b279d1c89f4a0a1df7bd8dde2 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 10 Dec 2015 20:20:14 +0100 Subject: [PATCH] ipa-cp.c (ipcp_cloning_candidate_p): Use node->optimize_for_size_p. * ipa-cp.c (ipcp_cloning_candidate_p): Use node->optimize_for_size_p. (good_cloning_opportunity_p): Likewise. (gather_context_independent_values): Do not return true when polymorphic call context is known or when we have known aggregate value of unused parameter. (estimate_local_effects): Try to create clone for all context when either some params are substituted or devirtualization is possible or some params can be removed; use local flag instead of node->will_be_removed_from_program_if_no_direct_calls_p. (identify_dead_nodes): Likewise. * gcc.c-torture/execute/20010122-1.c: Disable cloning. From-SVN: r231540 --- gcc/ChangeLog | 13 ++++++++ gcc/ipa-cp.c | 30 +++++++++++-------- gcc/testsuite/ChangeLog | 4 +++ .../gcc.c-torture/execute/20010122-1.c | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eabb30d4679..fb1cb06a7f4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2015-12-10 Jan Hubicka + + * ipa-cp.c (ipcp_cloning_candidate_p): Use node->optimize_for_size_p. + (good_cloning_opportunity_p): Likewise. + (gather_context_independent_values): Do not return true when + polymorphic call context is known or when we have known aggregate + value of unused parameter. + (estimate_local_effects): Try to create clone for all context + when either some params are substituted or devirtualization is possible + or some params can be removed; use local flag instead of + node->will_be_removed_from_program_if_no_direct_calls_p. + (identify_dead_nodes): Likewise. + 2015-12-10 David Malcolm * doc/invoke.texi (-Wall): Add -Wmisleading-indentation to the diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 6ba2f1493f8..ee285500608 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -613,7 +613,7 @@ ipcp_cloning_candidate_p (struct cgraph_node *node) return false; } - if (!optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node->decl))) + if (node->optimize_for_size_p ()) { if (dump_file) fprintf (dump_file, "Not considering %s for cloning; " @@ -2267,7 +2267,7 @@ good_cloning_opportunity_p (struct cgraph_node *node, int time_benefit, { if (time_benefit == 0 || !opt_for_fn (node->decl, flag_ipa_cp_clone) - || !optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node->decl))) + || node->optimize_for_size_p ()) return false; gcc_assert (size_cost > 0); @@ -2387,12 +2387,14 @@ gather_context_independent_values (struct ipa_node_params *info, *removable_params_cost += ipa_get_param_move_cost (info, i); + if (!ipa_is_param_used (info, i)) + continue; + ipcp_lattice *ctxlat = &plats->ctxlat; + /* Do not account known context as reason for cloning. We can see + if it permits devirtualization. */ if (ctxlat->is_single_const ()) - { - (*known_contexts)[i] = ctxlat->values->value; - ret = true; - } + (*known_contexts)[i] = ctxlat->values->value; if (known_aggs) { @@ -2494,7 +2496,9 @@ estimate_local_effects (struct cgraph_node *node) &known_contexts, &known_aggs, &removable_params_cost); known_aggs_ptrs = agg_jmp_p_vec_for_t_vec (known_aggs); - if (always_const) + int devirt_bonus = devirtualization_time_bonus (node, known_csts, + known_contexts, known_aggs_ptrs); + if (always_const || devirt_bonus || removable_params_cost) { struct caller_statistics stats; inline_hints hints; @@ -2505,8 +2509,7 @@ estimate_local_effects (struct cgraph_node *node) false); estimate_ipcp_clone_size_and_time (node, known_csts, known_contexts, known_aggs_ptrs, &size, &time, &hints); - time -= devirtualization_time_bonus (node, known_csts, known_contexts, - known_aggs_ptrs); + time -= devirt_bonus; time -= hint_time_bonus (hints); time -= removable_params_cost; size -= stats.n_calls * removable_params_cost; @@ -2515,8 +2518,7 @@ estimate_local_effects (struct cgraph_node *node) fprintf (dump_file, " - context independent values, size: %i, " "time_benefit: %i\n", size, base_time - time); - if (size <= 0 - || node->will_be_removed_from_program_if_no_direct_calls_p ()) + if (size <= 0 || node->local.local) { info->do_clone_for_all_contexts = true; base_time = time; @@ -2544,6 +2546,10 @@ estimate_local_effects (struct cgraph_node *node) "max_new_size would be reached with %li.\n", size + overall_size); } + else if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Not cloning for all contexts because " + "!good_cloning_opportunity_p.\n"); + } for (i = 0; i < count ; i++) @@ -4419,7 +4425,7 @@ identify_dead_nodes (struct cgraph_node *node) { struct cgraph_node *v; for (v = node; v ; v = ((struct ipa_dfs_info *) v->aux)->next_cycle) - if (v->will_be_removed_from_program_if_no_direct_calls_p () + if (v->local.local && !v->call_for_symbol_thunks_and_aliases (has_undead_caller_from_outside_scc_p, NULL, true)) IPA_NODE_REF (v)->node_dead = 1; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fec376037d0..ef97e761d45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-12-10 Jan Hubicka + + * gcc.c-torture/execute/20010122-1.c: Disable cloning. + 2015-12-10 Vladimir Makarov PR rtl-optimization/68691 diff --git a/gcc/testsuite/gcc.c-torture/execute/20010122-1.c b/gcc/testsuite/gcc.c-torture/execute/20010122-1.c index 528cef7139d..4eeb8c7a30b 100644 --- a/gcc/testsuite/gcc.c-torture/execute/20010122-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/20010122-1.c @@ -6,7 +6,7 @@ extern void abort (void); extern void *alloca (__SIZE_TYPE__); char *dummy (void); -#define NOINLINE __attribute__((noinline)) +#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone)) void *save_ret1[6]; void *test4a (char *); -- 2.30.2