diff mbox

[09/13] Eliminate profile_status macro.

Message ID 1386341499-19603-10-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Dec. 6, 2013, 2:51 p.m. UTC
gcc/
	* basic-block.h (profile_status): Eliminate macro.

	* cfgbuild.c (find_many_sub_basic_blocks): Eliminate use of
	profile_status macro in favor of profile_status_for_fn, making
	use of cfun explicit.
	* cfghooks.c (account_profile_record): Likewise.
	* cfgloopanal.c (single_likely_exit):
	* cfgrtl.c (rtl_verify_edges, rtl_account_profile_record): Likewise.
	* graphite.c (graphite_finalize):
	* internal-fn.c (ubsan_expand_si_overflow_addsub_check,
	ubsan_expand_si_overflow_neg_check,
	ubsan_expand_si_overflow_mul_check): Likewise.
	* ipa-split.c (consider_split, execute_split_functions):
	* loop-unroll.c (decide_peel_simple):
	* optabs.c (emit_cmp_and_jump_insn_1):
	* predict.c (maybe_hot_edge_p, probably_never_executed,
	predictable_edge_p, probability_reliable_p, gimple_predict_edge,
	tree_estimate_probability_driver, estimate_bb_frequencies,
	compute_function_frequency, rebuild_frequencies): Likewise.
	* profile.c (compute_branch_probabilities): Likewise.
	* tree-cfg.c (gimple_account_profile_record): Likewise.
	* tree-inline.c (optimize_inline_calls): Likewise.
---
 gcc/basic-block.h |  1 -
 gcc/cfgbuild.c    |  2 +-
 gcc/cfghooks.c    |  4 ++--
 gcc/cfgloopanal.c |  2 +-
 gcc/cfgrtl.c      |  6 +++---
 gcc/graphite.c    |  2 +-
 gcc/internal-fn.c |  6 +++---
 gcc/ipa-split.c   |  4 ++--
 gcc/loop-unroll.c |  2 +-
 gcc/optabs.c      |  2 +-
 gcc/predict.c     | 26 +++++++++++++-------------
 gcc/profile.c     |  4 ++--
 gcc/tree-cfg.c    |  4 ++--
 gcc/tree-inline.c |  3 ++-
 14 files changed, 34 insertions(+), 34 deletions(-)
diff mbox

Patch

diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 4ab8289..d000a43 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -328,7 +328,6 @@  struct GTY(()) control_flow_graph {
 
 /* Defines for textual backward source compatibility.  */
 #define last_basic_block	(cfun->cfg->x_last_basic_block)
-#define profile_status		(cfun->cfg->x_profile_status)
 
 /* For iterating over basic blocks.  */
 #define FOR_BB_BETWEEN(BB, FROM, TO, DIR) \
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 08534d4..a0c2c66 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -618,7 +618,7 @@  find_many_sub_basic_blocks (sbitmap blocks)
 
   /* Update branch probabilities.  Expect only (un)conditional jumps
      to be created with only the forward edges.  */
-  if (profile_status != PROFILE_ABSENT)
+  if (profile_status_for_fn (cfun) != PROFILE_ABSENT)
     FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
       {
 	edge e;
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 0cd6af0..ab1c15f 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -1411,7 +1411,7 @@  account_profile_record (struct profile_record *record, int after_pass)
   FOR_ALL_BB (bb)
    {
       if (bb != EXIT_BLOCK_PTR_FOR_FN (cfun)
-	  && profile_status != PROFILE_ABSENT)
+	  && profile_status_for_fn (cfun) != PROFILE_ABSENT)
 	{
 	  sum = 0;
 	  FOR_EACH_EDGE (e, ei, bb->succs)
@@ -1426,7 +1426,7 @@  account_profile_record (struct profile_record *record, int after_pass)
 	    record->num_mismatched_count_out[after_pass]++;
 	}
       if (bb != ENTRY_BLOCK_PTR_FOR_FN (cfun)
-	  && profile_status != PROFILE_ABSENT)
+	  && profile_status_for_fn (cfun) != PROFILE_ABSENT)
 	{
 	  sum = 0;
 	  FOR_EACH_EDGE (e, ei, bb->preds)
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index 0cee6c6..2260f4b 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -470,7 +470,7 @@  single_likely_exit (struct loop *loop)
 	 ruled out by this test.  The static branch prediction algorithm
          will not assign such a low probability to conditionals for usual
          reasons.  */
-      if (profile_status != PROFILE_ABSENT
+      if (profile_status_for_fn (cfun) != PROFILE_ABSENT
 	  && ex->probability < 5 && !ex->count)
 	continue;
       if (!found)
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 772d939..34fe4f3 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -2420,7 +2420,7 @@  rtl_verify_edges (void)
 	  && any_condjump_p (BB_END (bb)))
 	{
 	  if (XINT (note, 0) != BRANCH_EDGE (bb)->probability
-	      && profile_status != PROFILE_ABSENT)
+	      && profile_status_for_fn (cfun) != PROFILE_ABSENT)
 	    {
 	      error ("verify_flow_info: REG_BR_PROB does not match cfg %i %i",
 		     XINT (note, 0), BRANCH_EDGE (bb)->probability);
@@ -5011,10 +5011,10 @@  rtl_account_profile_record (basic_block bb, int after_pass,
       {
 	record->size[after_pass]
 	  += insn_rtx_cost (PATTERN (insn), false);
-	if (profile_status == PROFILE_READ)
+	if (profile_status_for_fn (cfun) == PROFILE_READ)
 	  record->time[after_pass]
 	    += insn_rtx_cost (PATTERN (insn), true) * bb->count;
-	else if (profile_status == PROFILE_GUESSED)
+	else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
 	  record->time[after_pass]
 	    += insn_rtx_cost (PATTERN (insn), true) * bb->frequency;
       }
diff --git a/gcc/graphite.c b/gcc/graphite.c
index e46710c..a573ea7 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -245,7 +245,7 @@  graphite_finalize (bool need_cfg_cleanup_p)
     {
       scev_reset ();
       cleanup_tree_cfg ();
-      profile_status = PROFILE_ABSENT;
+      profile_status_for_fn (cfun) = PROFILE_ABSENT;
       release_recorded_exits ();
       tree_estimate_probability ();
     }
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c
index fb1e578..8c54d98 100644
--- a/gcc/internal-fn.c
+++ b/gcc/internal-fn.c
@@ -194,7 +194,7 @@  ubsan_expand_si_overflow_addsub_check (tree_code code, gimple stmt)
       if (maybe_expand_insn (icode, 4, ops))
 	{
 	  last = get_last_insn ();
-	  if (profile_status != PROFILE_ABSENT
+	  if (profile_status_for_fn (cfun) != PROFILE_ABSENT
 	      && JUMP_P (last)
 	      && any_condjump_p (last)
 	      && !find_reg_note (last, REG_BR_PROB, 0))
@@ -285,7 +285,7 @@  ubsan_expand_si_overflow_neg_check (gimple stmt)
       if (maybe_expand_insn (icode, 3, ops))
 	{
 	  last = get_last_insn ();
-	  if (profile_status != PROFILE_ABSENT
+	  if (profile_status_for_fn (cfun) != PROFILE_ABSENT
 	      && JUMP_P (last)
 	      && any_condjump_p (last)
 	      && !find_reg_note (last, REG_BR_PROB, 0))
@@ -364,7 +364,7 @@  ubsan_expand_si_overflow_mul_check (gimple stmt)
       if (maybe_expand_insn (icode, 4, ops))
 	{
 	  last = get_last_insn ();
-	  if (profile_status != PROFILE_ABSENT
+	  if (profile_status_for_fn (cfun) != PROFILE_ABSENT
 	      && JUMP_P (last)
 	      && any_condjump_p (last)
 	      && !find_reg_note (last, REG_BR_PROB, 0))
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index eca86da..f8fa0ee 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -411,7 +411,7 @@  consider_split (struct split_point *current, bitmap non_ssa_vars,
 	 a loop, enable splitting since inlining code skipping the loop
 	 is likely noticeable win.  */
       if (back_edge
-	  && profile_status != PROFILE_READ
+	  && profile_status_for_fn (cfun) != PROFILE_READ
 	  && incoming_freq < ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency)
 	{
 	  if (dump_file && (dump_flags & TDF_DETAILS))
@@ -1585,7 +1585,7 @@  execute_split_functions (void)
 
   /* We enforce splitting after loop headers when profile info is not
      available.  */
-  if (profile_status != PROFILE_READ)
+  if (profile_status_for_fn (cfun) != PROFILE_READ)
     mark_dfs_back_edges ();
 
   /* Initialize bitmap to track forbidden calls.  */
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 9910b4e..d1c7b9c 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -1371,7 +1371,7 @@  decide_peel_simple (struct loop *loop, int flags)
      also branch from branch prediction POV (and probably better reason
      to not unroll/peel).  */
   if (num_loop_branches (loop) > 1
-      && profile_status != PROFILE_READ)
+      && profile_status_for_fn (cfun) != PROFILE_READ)
     {
       if (dump_file)
 	fprintf (dump_file, ";; Not peeling, contains branches\n");
diff --git a/gcc/optabs.c b/gcc/optabs.c
index e035af1..5172bd4 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -4286,7 +4286,7 @@  emit_cmp_and_jump_insn_1 (rtx test, enum machine_mode mode, rtx label, int prob)
   insn = emit_jump_insn (GEN_FCN (icode) (test, XEXP (test, 0),
                                           XEXP (test, 1), label));
   if (prob != -1
-      && profile_status != PROFILE_ABSENT
+      && profile_status_for_fn (cfun) != PROFILE_ABSENT
       && insn
       && JUMP_P (insn)
       && any_condjump_p (insn)
diff --git a/gcc/predict.c b/gcc/predict.c
index 1dec4dc..6bb1b2c 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -224,7 +224,7 @@  cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
 bool
 maybe_hot_edge_p (edge e)
 {
-  if (profile_status == PROFILE_READ)
+  if (profile_status_for_fn (cfun) == PROFILE_READ)
     return maybe_hot_count_p (cfun, e->count);
   return maybe_hot_frequency_p (cfun, EDGE_FREQUENCY (e));
 }
@@ -239,7 +239,7 @@  probably_never_executed (struct function *fun,
                          gcov_type count, int frequency)
 {
   gcc_checking_assert (fun);
-  if (profile_status_for_fn (fun) == PROFILE_READ)
+  if (profile_status_for_fn (cfun) == PROFILE_READ)
     {
       int unlikely_count_fraction = PARAM_VALUE (UNLIKELY_BB_COUNT_FRACTION);
       if (count * unlikely_count_fraction >= profile_info->runs)
@@ -438,7 +438,7 @@  optimize_loop_nest_for_size_p (struct loop *loop)
 bool
 predictable_edge_p (edge e)
 {
-  if (profile_status == PROFILE_ABSENT)
+  if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
     return false;
   if ((e->probability
        <= PARAM_VALUE (PARAM_PREDICTABLE_BRANCH_OUTCOME) * REG_BR_PROB_BASE / 100)
@@ -539,8 +539,8 @@  gimple_predicted_by_p (const_basic_block bb, enum br_predictor predictor)
 static bool
 probability_reliable_p (int prob)
 {
-  return (profile_status == PROFILE_READ
-	  || (profile_status == PROFILE_GUESSED
+  return (profile_status_for_fn (cfun) == PROFILE_READ
+	  || (profile_status_for_fn (cfun) == PROFILE_GUESSED
 	      && (prob <= HITRATE (1) || prob >= HITRATE (99))));
 }
 
@@ -610,7 +610,7 @@  rtl_predict_edge (edge e, enum br_predictor predictor, int probability)
 void
 gimple_predict_edge (edge e, enum br_predictor predictor, int probability)
 {
-  gcc_assert (profile_status != PROFILE_GUESSED);
+  gcc_assert (profile_status_for_fn (cfun) != PROFILE_GUESSED);
   if ((e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) && EDGE_COUNT (e->src->succs) >
        1)
       && flag_guess_branch_prob && optimize)
@@ -2443,8 +2443,8 @@  tree_estimate_probability_driver (void)
   loop_optimizer_finalize ();
   if (dump_file && (dump_flags & TDF_DETAILS))
     gimple_dump_cfg (dump_file, dump_flags);
-  if (profile_status == PROFILE_ABSENT)
-    profile_status = PROFILE_GUESSED;
+  if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
+    profile_status_for_fn (cfun) = PROFILE_GUESSED;
   return 0;
 }
 
@@ -2954,7 +2954,7 @@  estimate_bb_frequencies (bool force)
   basic_block bb;
   sreal freq_max;
 
-  if (force || profile_status != PROFILE_READ || !counts_to_freqs ())
+  if (force || profile_status_for_fn (cfun) != PROFILE_READ || !counts_to_freqs ())
     {
       static int real_values_initialized = 0;
 
@@ -3030,7 +3030,7 @@  compute_function_frequency (void)
   if (DECL_STATIC_DESTRUCTOR (current_function_decl))
     node->only_called_at_exit = true;
 
-  if (profile_status != PROFILE_READ)
+  if (profile_status_for_fn (cfun) != PROFILE_READ)
     {
       int flags = flags_from_decl_or_type (current_function_decl);
       if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
@@ -3189,8 +3189,8 @@  rebuild_frequencies (void)
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
     count_max = MAX (bb->count, count_max);
 
-  if (profile_status == PROFILE_GUESSED
-      || (profile_status == PROFILE_READ && count_max < REG_BR_PROB_BASE/10))
+  if (profile_status_for_fn (cfun) == PROFILE_GUESSED
+      || (profile_status_for_fn (cfun) == PROFILE_READ && count_max < REG_BR_PROB_BASE/10))
     {
       loop_optimizer_init (0);
       add_noreturn_fake_exit_edges ();
@@ -3200,7 +3200,7 @@  rebuild_frequencies (void)
       remove_fake_exit_edges ();
       loop_optimizer_finalize ();
     }
-  else if (profile_status == PROFILE_READ)
+  else if (profile_status_for_fn (cfun) == PROFILE_READ)
     counts_to_freqs ();
   else
     gcc_unreachable ();
diff --git a/gcc/profile.c b/gcc/profile.c
index 9aec3cb..24c16aa 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -797,7 +797,7 @@  compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 	 give all abnormals frequency of 0, otherwise distribute the
 	 frequency over abnormals (this is the case of noreturn
 	 calls).  */
-      else if (profile_status == PROFILE_ABSENT)
+      else if (profile_status_for_fn (cfun) == PROFILE_ABSENT)
 	{
 	  int total = 0;
 
@@ -825,7 +825,7 @@  compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 	}
     }
   counts_to_freqs ();
-  profile_status = PROFILE_READ;
+  profile_status_for_fn (cfun) = PROFILE_READ;
   compute_function_frequency ();
 
   if (dump_file)
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index f384b04..57d6487 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7875,11 +7875,11 @@  gimple_account_profile_record (basic_block bb, int after_pass,
     {
       record->size[after_pass]
 	+= estimate_num_insns (gsi_stmt (i), &eni_size_weights);
-      if (profile_status == PROFILE_READ)
+      if (profile_status_for_fn (cfun) == PROFILE_READ)
 	record->time[after_pass]
 	  += estimate_num_insns (gsi_stmt (i),
 				 &eni_time_weights) * bb->count;
-      else if (profile_status == PROFILE_GUESSED)
+      else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
 	record->time[after_pass]
 	  += estimate_num_insns (gsi_stmt (i),
 				 &eni_time_weights) * bb->frequency;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 1d1bc1e..fd7eedb 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -4612,7 +4612,8 @@  optimize_inline_calls (tree fn)
 	  | TODO_cleanup_cfg
 	  | (gimple_in_ssa_p (cfun) ? TODO_remove_unused_locals : 0)
 	  | (gimple_in_ssa_p (cfun) ? TODO_update_address_taken : 0)
-	  | (profile_status != PROFILE_ABSENT ? TODO_rebuild_frequencies : 0));
+	  | (profile_status_for_fn (cfun) != PROFILE_ABSENT
+	     ? TODO_rebuild_frequencies : 0));
 }
 
 /* Passed to walk_tree.  Copies the node pointed to, if appropriate.  */