predict.c (maybe_hot_count_p, [...]): When profile is present, use only counts; when...
authorJan Hubicka <jh@suse.cz>
Mon, 1 Sep 2008 16:28:06 +0000 (18:28 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 1 Sep 2008 16:28:06 +0000 (16:28 +0000)
* predict.c (maybe_hot_count_p, maybe_hot_edge_p): When profile is
present, use only counts; when guessed use only frequencies.
(estimate_bb_frequencies): Use function_frequency.
* profile.c (compute_branch_probabilities): Exit early when
profile reading failed. Set profile_status.
(branch_prob): Do not set profile_status.

From-SVN: r139868

gcc/ChangeLog
gcc/predict.c
gcc/profile.c

index 16cb50cda164f6334e76ec02ed1f6ae19a77b7f7..a6bc7c1dfbbf06abba73c1d31a74de11cc1ac951 100644 (file)
@@ -1,3 +1,12 @@
+2008-09-01  Jan Hubicka  <jh@suse.cz>
+
+       * predict.c (maybe_hot_count_p, maybe_hot_edge_p): When profile is
+       present, use only counts; when guessed use only frequencies.
+       (estimate_bb_frequencies): Use function_frequency.
+       * profile.c (compute_branch_probabilities): Exit early when
+       profile reading failed. Set profile_status.
+       (branch_prob): Do not set profile_status.
+
 2008-09-01  Aldy Hernandez  <aldyh@redhat.com>
 
        * tree.c (protected_set_expr_location): New.
index 41a9ee32eb8208dbc409661d164d88ca5c4027b0..1c877ec06b15add7602112fae3a726ac0b75f81c 100644 (file)
@@ -148,7 +148,9 @@ maybe_hot_count_p (gcov_type count)
 bool
 maybe_hot_bb_p (const_basic_block bb)
 {
-  return maybe_hot_count_p (bb->count) && maybe_hot_frequency_p (bb->frequency);
+  if (profile_status == PROFILE_READ)
+    return maybe_hot_count_p (bb->count);
+  return maybe_hot_frequency_p (bb->frequency);
 }
 
 /* Return true if the call can be hot.  */
@@ -178,7 +180,9 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
 bool
 maybe_hot_edge_p (edge e)
 {
-  return maybe_hot_count_p (e->count) && maybe_hot_frequency_p (EDGE_FREQUENCY (e));
+  if (profile_status == PROFILE_READ)
+    return maybe_hot_count_p (e->count);
+  return maybe_hot_frequency_p (EDGE_FREQUENCY (e));
 }
 
 /* Return true in case BB is probably never executed.  */
@@ -2009,7 +2013,7 @@ estimate_bb_frequencies (void)
   basic_block bb;
   sreal freq_max;
 
-  if (!flag_branch_probabilities || !counts_to_freqs ())
+  if (cfun->function_frequency != PROFILE_READ || !counts_to_freqs ())
     {
       static int real_values_initialized = 0;
 
index 6f89645d1fbb3b3f114ca86b5c463548ea7f4d20..883515d9a17cfce39eea16412752960ba946011c 100644 (file)
@@ -402,19 +402,18 @@ compute_branch_probabilities (void)
   int inconsistent = 0;
 
   /* Very simple sanity checks so we catch bugs in our profiling code.  */
-  if (profile_info)
+  if (!profile_info)
+    return;
+  if (profile_info->run_max * profile_info->runs < profile_info->sum_max)
     {
-      if (profile_info->run_max * profile_info->runs < profile_info->sum_max)
-        {
-          error ("corrupted profile info: run_max * runs < sum_max");
-          exec_counts = NULL;
-        }
+      error ("corrupted profile info: run_max * runs < sum_max");
+      exec_counts = NULL;
+    }
 
-      if (profile_info->sum_all < profile_info->sum_max)
-        {
-          error ("corrupted profile info: sum_all is smaller than sum_max");
-          exec_counts = NULL;
-        }
+  if (profile_info->sum_all < profile_info->sum_max)
+    {
+      error ("corrupted profile info: sum_all is smaller than sum_max");
+      exec_counts = NULL;
     }
 
   /* Attach extra info block to each bb.  */
@@ -695,6 +694,7 @@ compute_branch_probabilities (void)
        }
     }
   counts_to_freqs ();
+  profile_status = PROFILE_READ;
 
   if (dump_file)
     {
@@ -1154,8 +1154,6 @@ branch_prob (void)
 
   VEC_free (histogram_value, heap, values);
   free_edge_list (el);
-  if (flag_branch_probabilities && profile_info)
-    profile_status = PROFILE_READ;
   coverage_end_function ();
 }
 \f