predict.c (probably_never_executed): Only use precise profile info.
authorJan Hubicka <hubicka@ucw.cz>
Tue, 23 Jan 2018 09:55:37 +0000 (10:55 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 23 Jan 2018 09:55:37 +0000 (09:55 +0000)
* predict.c (probably_never_executed): Only use precise profile info.
(compute_function_frequency): Skip after inlining hack since we now
have quality checking.

From-SVN: r256975

gcc/ChangeLog
gcc/predict.c

index 4a29b02e488033e4379155946c0662bea3150c74..747c3b48ab9fc185a19583792250aca63ba29410 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-23  Jan Hubicka  <hubicka@ucw.cz>
+
+       * predict.c (probably_never_executed): Only use precise profile info.
+       (compute_function_frequency): Skip after inlining hack since we now
+       have quality checking.
+
 2018-01-23  Jan Hubicka  <hubicka@ucw.cz>
 
        * profile-count.h (profile_probability::very_unlikely,
index 340c76674344b663a63f10186d9f7ba28795dbb9..724ba458db9c6bff6d3337e21801bc87035e06c4 100644 (file)
@@ -212,7 +212,12 @@ probably_never_executed (struct function *fun,
   gcc_checking_assert (fun);
   if (count == profile_count::zero ())
     return true;
-  if (count.initialized_p () && profile_status_for_fn (fun) == PROFILE_READ)
+  /* Do not trust adjusted counts.  This will make us to drop int cold section
+     code with low execution count as a result of inlining. These low counts
+     are not safe even with read profile and may lead us to dropping
+     code which actually gets executed into cold section of binary that is not
+     desirable.  */
+  if (count.precise_p () && profile_status_for_fn (fun) == PROFILE_READ)
     {
       int unlikely_count_fraction = PARAM_VALUE (UNLIKELY_BB_COUNT_FRACTION);
       if (count.apply_scale (unlikely_count_fraction, 1) >= profile_info->runs)
@@ -3759,15 +3764,10 @@ compute_function_frequency (void)
       return;
     }
 
-  /* Only first time try to drop function into unlikely executed.
-     After inlining the roundoff errors may confuse us.
-     Ipa-profile pass will drop functions only called from unlikely
-     functions to unlikely and that is most of what we care about.  */
-  if (!cfun->after_inlining)
-    {
-      node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
-      warn_function_cold (current_function_decl);
-    }
+  node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
+  warn_function_cold (current_function_decl);
+  if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa() == profile_count::zero ())
+    return;
   FOR_EACH_BB_FN (bb, cfun)
     {
       if (maybe_hot_bb_p (cfun, bb))