From 9e4315edb65a2a929cc48772eb10c194328d8023 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 18 Jun 2014 16:47:12 -0400
Subject: [PATCH 092/156] predict.*: Use rtx_insn (also touches function.c and
 config/cris/cris.c)

gcc/
	* predict.h (predict_insn_def): Strengthen param "insn" from rtx
	to rtx_insn *.

	* function.c (stack_protect_epilogue): Add checked cast to
	rtx_insn for now when invoking predict_insn_def.

	* predict.c (predict_insn): Strengthen param "insn" from rtx to
	rtx_insn *.
	(predict_insn_def): Likewise.
	(rtl_predict_edge): Likewise for local "last_insn".
	(can_predict_insn_p): Strengthen param "insn" from const_rtx to
	const rtx_insn *.
	(combine_predictions_for_insn): Strengthen param "insn" from rtx
	to rtx_insn *.
	(bb_estimate_probability_locally): Likewise for local "last_insn".
	(expensive_function_p): Likewise for local "insn".

	* config/cris/cris.c (cris_emit_trap_for_misalignment): Likewise for
	local "jmp", since this is used when invoking predict_insn_def.
---
 gcc/config/cris/cris.c |  3 ++-
 gcc/function.c         |  2 +-
 gcc/predict.c          | 18 +++++++++---------
 gcc/predict.h          |  2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index 194dd14..56adf45 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -1987,7 +1987,8 @@ cris_simple_epilogue (void)
 void
 cris_emit_trap_for_misalignment (rtx mem)
 {
-  rtx addr, reg, ok_label, andop, jmp;
+  rtx addr, reg, ok_label, andop;
+  rtx_insn *jmp;
   int natural_alignment;
   gcc_assert (MEM_P (mem));
 
diff --git a/gcc/function.c b/gcc/function.c
index b2c9d81..c5619e9 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4675,7 +4675,7 @@ stack_protect_epilogue (void)
      except adding the prediction by hand.  */
   tmp = get_last_insn ();
   if (JUMP_P (tmp))
-    predict_insn_def (tmp, PRED_NORETURN, TAKEN);
+    predict_insn_def (as_a <rtx_insn *> (tmp), PRED_NORETURN, TAKEN);
 
   expand_call (targetm.stack_protect_fail (), NULL_RTX, /*ignore=*/true);
   free_temp_slots ();
diff --git a/gcc/predict.c b/gcc/predict.c
index 55a645d..e08c982 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -74,11 +74,11 @@ along with GCC; see the file COPYING3.  If not see
 static sreal real_zero, real_one, real_almost_one, real_br_prob_base,
 	     real_inv_br_prob_base, real_one_half, real_bb_freq_max;
 
-static void combine_predictions_for_insn (rtx, basic_block);
+static void combine_predictions_for_insn (rtx_insn *, basic_block);
 static void dump_prediction (FILE *, enum br_predictor, int, basic_block, int);
 static void predict_paths_leading_to (basic_block, enum br_predictor, enum prediction);
 static void predict_paths_leading_to_edge (edge, enum br_predictor, enum prediction);
-static bool can_predict_insn_p (const_rtx);
+static bool can_predict_insn_p (const rtx_insn *);
 
 /* Information we hold about each branch predictor.
    Filled using information from predict.def.  */
@@ -560,7 +560,7 @@ br_prob_note_reliable_p (const_rtx note)
 }
 
 static void
-predict_insn (rtx insn, enum br_predictor predictor, int probability)
+predict_insn (rtx_insn *insn, enum br_predictor predictor, int probability)
 {
   gcc_assert (any_condjump_p (insn));
   if (!flag_guess_branch_prob)
@@ -575,7 +575,7 @@ predict_insn (rtx insn, enum br_predictor predictor, int probability)
 /* Predict insn by given predictor.  */
 
 void
-predict_insn_def (rtx insn, enum br_predictor predictor,
+predict_insn_def (rtx_insn *insn, enum br_predictor predictor,
 		  enum prediction taken)
 {
    int probability = predictor_info[(int) predictor].hitrate;
@@ -591,7 +591,7 @@ predict_insn_def (rtx insn, enum br_predictor predictor,
 void
 rtl_predict_edge (edge e, enum br_predictor predictor, int probability)
 {
-  rtx last_insn;
+  rtx_insn *last_insn;
   last_insn = BB_END (e->src);
 
   /* We can store the branch prediction information only about
@@ -680,7 +680,7 @@ clear_bb_predictions (basic_block bb)
    At the moment we represent predictions only on conditional
    jumps, not at computed jump or other complicated cases.  */
 static bool
-can_predict_insn_p (const_rtx insn)
+can_predict_insn_p (const rtx_insn *insn)
 {
   return (JUMP_P (insn)
 	  && any_condjump_p (insn)
@@ -773,7 +773,7 @@ set_even_probabilities (basic_block bb)
    note if not already present.  Remove now useless REG_BR_PRED notes.  */
 
 static void
-combine_predictions_for_insn (rtx insn, basic_block bb)
+combine_predictions_for_insn (rtx_insn *insn, basic_block bb)
 {
   rtx prob_note;
   rtx *pnote;
@@ -1668,7 +1668,7 @@ predict_loops (void)
 static void
 bb_estimate_probability_locally (basic_block bb)
 {
-  rtx last_insn = BB_END (bb);
+  rtx_insn *last_insn = BB_END (bb);
   rtx cond;
 
   if (! can_predict_insn_p (last_insn))
@@ -2891,7 +2891,7 @@ expensive_function_p (int threshold)
   limit = ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency * threshold;
   FOR_EACH_BB_FN (bb, cfun)
     {
-      rtx insn;
+      rtx_insn *insn;
 
       FOR_BB_INSNS (bb, insn)
 	if (active_insn_p (insn))
diff --git a/gcc/predict.h b/gcc/predict.h
index 1555f80..c75b6b6 100644
--- a/gcc/predict.h
+++ b/gcc/predict.h
@@ -45,7 +45,7 @@ enum prediction
    TAKEN
 };
 
-extern void predict_insn_def (rtx, enum br_predictor, enum prediction);
+extern void predict_insn_def (rtx_insn *, enum br_predictor, enum prediction);
 extern int counts_to_freqs (void);
 extern void handle_missing_profiles (void);
 extern void estimate_bb_frequencies (bool);
-- 
1.8.5.3

