OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / predict.c
index 41a9ee3..c6e933f 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.  */
@@ -199,7 +203,8 @@ bool
 optimize_function_for_size_p (struct function *fun)
 {
   return (optimize_size
-         || fun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED);
+         || (fun && (fun->function_frequency
+                     == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)));
 }
 
 /* Return true when current function should always be optimized for speed.  */
@@ -1594,6 +1599,7 @@ tree_estimate_probability (void)
     {
       edge e;
       edge_iterator ei;
+      gimple last;
 
       FOR_EACH_EDGE (e, ei, bb->succs)
        {
@@ -1616,7 +1622,8 @@ tree_estimate_probability (void)
              && e->dest != EXIT_BLOCK_PTR
              && single_succ_p (e->dest)
              && single_succ_edge (e->dest)->dest == EXIT_BLOCK_PTR
-             && gimple_code (last_stmt (e->dest)) == GIMPLE_RETURN)
+             && (last = last_stmt (e->dest)) != NULL
+             && gimple_code (last) == GIMPLE_RETURN)
            {
              edge e1;
              edge_iterator ei1;
@@ -2009,7 +2016,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;
 
@@ -2175,7 +2182,7 @@ struct gimple_opt_pass pass_strip_predict_hints =
 {
  {
   GIMPLE_PASS,
-  "",                                  /* name */
+  NULL,                                        /* name */
   NULL,                                        /* gate */
   strip_predict_hints,                 /* execute */
   NULL,                                        /* sub */