ipa-cp.c (ipcp_cloning_candidate_p): Use node->optimize_for_size_p.
authorJan Hubicka <hubicka@ucw.cz>
Thu, 10 Dec 2015 19:20:14 +0000 (20:20 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 10 Dec 2015 19:20:14 +0000 (19:20 +0000)
* 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
gcc/ipa-cp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20010122-1.c

index eabb30d46799910ce6112df87b438f53de596142..fb1cb06a7f428d458754493b3b2e0cc230cc6d9d 100644 (file)
@@ -1,3 +1,16 @@
+2015-12-10  Jan Hubicka  <hubicka@ucw.cz>
+
+       * 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  <dmalcolm@redhat.com>
 
        * doc/invoke.texi (-Wall): Add -Wmisleading-indentation to the
index 6ba2f1493f8610d03d2973cb5aaacadec21e2379..ee285500608664720a8b617761db8403b5c0f50b 100644 (file)
@@ -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<ipa_polymorphic_call_context> *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;
index fec376037d0d53fc7bd1c8aef623215f38e82ec3..ef97e761d45b26087ec25c501c6c459e4bc529a0 100644 (file)
@@ -1,3 +1,7 @@
+2015-12-10  Jan Hubicka  <hubicka@ucw.cz>
+
+       * gcc.c-torture/execute/20010122-1.c: Disable cloning.
+
 2015-12-10  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/68691
index 528cef7139d76371559461f43279748b4e46f859..4eeb8c7a30bd556ac8a01970164ceb6690da1c6e 100644 (file)
@@ -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 *);