From 7fb24446649ceee9e3302d897b3095dfe5656100 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 17 Jun 2014 16:11:55 -0400
Subject: [PATCH 35/60] dce.c: Use rtx subclasses

gcc/
	* dce.c (deletable_insn_p): Strengthen param "insn" from rtx to
	rtx_insn *.  Add checked cast to rtx_call_insn when invoking
	find_call_stack_args, since this is guarded by CALL_P (insn).
	(mark_insn): Add checked cast to rtx_call_insn when invoking
	find_call_stack_args, since this is guarded by CALL_P (insn).
	(mark_nonreg_stores): Strengthen param "insn" from rtx to
	rtx_insn *.
	(find_call_stack_args): Strengthen param "call_insn" from rtx to
	rtx_call_insn *; strengthen locals "insn" and "prev_insn" from rtx
	to rtx_insn *.
	(remove_reg_equal_equiv_notes_for_defs): Strengthen param "insn"
	from rtx to rtx_insn *.
	(reset_unmarked_insns_debug_uses): Likewise for locals "insn",
	"next".
	(delete_unmarked_insns): Likewise.
	(prescan_insns_for_dce): Likewise for locals "insn", "prev".
	(word_dce_process_block): Likewise for local "insn".
	(dce_process_block): Likewise.
---
 gcc/dce.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/gcc/dce.c b/gcc/dce.c
index 0e24577..df57941 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -60,7 +60,7 @@ static sbitmap marked;
 static bitmap_obstack dce_blocks_bitmap_obstack;
 static bitmap_obstack dce_tmp_bitmap_obstack;
 
-static bool find_call_stack_args (rtx, bool, bool, bitmap);
+static bool find_call_stack_args (rtx_call_insn *, bool, bool, bitmap);
 
 /* A subroutine for which BODY is part of the instruction being tested;
    either the top-level pattern, or an element of a PARALLEL.  The
@@ -92,7 +92,7 @@ deletable_insn_p_1 (rtx body)
    the DCE pass.  */
 
 static bool
-deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
+deletable_insn_p (rtx_insn *insn, bool fast, bitmap arg_stores)
 {
   rtx body, x;
   int i;
@@ -109,7 +109,8 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
          infinite loop.  */
       && (RTL_CONST_OR_PURE_CALL_P (insn)
 	  && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
-    return find_call_stack_args (insn, false, fast, arg_stores);
+    return find_call_stack_args (as_a <rtx_call_insn *> (insn), false,
+				 fast, arg_stores);
 
   /* Don't delete jumps, notes and the like.  */
   if (!NONJUMP_INSN_P (insn))
@@ -190,7 +191,7 @@ mark_insn (rtx insn, bool fast)
 	  && !SIBLING_CALL_P (insn)
 	  && (RTL_CONST_OR_PURE_CALL_P (insn)
 	      && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
-	find_call_stack_args (insn, true, fast, NULL);
+	find_call_stack_args (as_a <rtx_call_insn *> (insn), true, fast, NULL);
     }
 }
 
@@ -220,7 +221,7 @@ mark_nonreg_stores_2 (rtx dest, const_rtx pattern, void *data)
 /* Mark INSN if BODY stores to a non-register destination.  */
 
 static void
-mark_nonreg_stores (rtx body, rtx insn, bool fast)
+mark_nonreg_stores (rtx body, rtx_insn *insn, bool fast)
 {
   if (fast)
     note_stores (body, mark_nonreg_stores_1, insn);
@@ -257,10 +258,11 @@ check_argument_store (rtx mem, HOST_WIDE_INT off, HOST_WIDE_INT min_sp_off,
    going to be marked called again with DO_MARK true.  */
 
 static bool
-find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
+find_call_stack_args (rtx_call_insn *call_insn, bool do_mark, bool fast,
 		      bitmap arg_stores)
 {
-  rtx p, insn, prev_insn;
+  rtx p;
+  rtx_insn *insn, *prev_insn;
   bool ret;
   HOST_WIDE_INT min_sp_off, max_sp_off;
   bitmap sp_bytes;
@@ -396,7 +398,7 @@ find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
       HOST_WIDE_INT off;
 
       if (insn == BB_HEAD (BLOCK_FOR_INSN (call_insn)))
-	prev_insn = NULL_RTX;
+	prev_insn = NULL;
       else
 	prev_insn = PREV_INSN (insn);
 
@@ -494,7 +496,7 @@ find_call_stack_args (rtx call_insn, bool do_mark, bool fast,
    writes to.  */
 
 static void
-remove_reg_equal_equiv_notes_for_defs (rtx insn)
+remove_reg_equal_equiv_notes_for_defs (rtx_insn *insn)
 {
   df_ref *def_rec;
 
@@ -509,7 +511,7 @@ static void
 reset_unmarked_insns_debug_uses (void)
 {
   basic_block bb;
-  rtx insn, next;
+  rtx_insn *insn, *next;
 
   FOR_EACH_BB_REVERSE_FN (bb, cfun)
     FOR_BB_INSNS_REVERSE_SAFE (bb, insn, next)
@@ -547,7 +549,7 @@ static void
 delete_unmarked_insns (void)
 {
   basic_block bb;
-  rtx insn, next;
+  rtx_insn *insn, *next;
   bool must_clean = false;
 
   FOR_EACH_BB_REVERSE_FN (bb, cfun)
@@ -614,7 +616,7 @@ static void
 prescan_insns_for_dce (bool fast)
 {
   basic_block bb;
-  rtx insn, prev;
+  rtx_insn *insn, *prev;
   bitmap arg_stores = NULL;
 
   if (dump_file)
@@ -839,7 +841,7 @@ word_dce_process_block (basic_block bb, bool redo_out,
 			struct dead_debug_global *global_debug)
 {
   bitmap local_live = BITMAP_ALLOC (&dce_tmp_bitmap_obstack);
-  rtx insn;
+  rtx_insn *insn;
   bool block_changed;
   struct dead_debug_local debug;
 
@@ -937,7 +939,7 @@ dce_process_block (basic_block bb, bool redo_out, bitmap au,
 		   struct dead_debug_global *global_debug)
 {
   bitmap local_live = BITMAP_ALLOC (&dce_tmp_bitmap_obstack);
-  rtx insn;
+  rtx_insn *insn;
   bool block_changed;
   df_ref *def_rec;
   struct dead_debug_local debug;
-- 
1.8.5.3

