From 46b7a04b3ef1e3088f2ee52c4801dee56f7ff52b Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 7 Jan 2014 16:52:20 -0500
Subject: [PATCH 088/159] FIXME: insn_could_throw_p

---
 gcc/emit-rtl.c |  5 +++--
 gcc/except.c   | 54 +++++++++++++++++++++++++++++++-----------------------
 gcc/reload1.c  |  2 +-
 gcc/rtl.h      |  6 +++---
 4 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index ab6c4b3..2d5a8d9 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3494,10 +3494,11 @@ try_split (rtx pat, rtx_base_insn trial, int last)
   rtx before = PREV_INSN (trial);
   rtx after = NEXT_INSN (trial);
   int has_barrier = 0;
-  rtx note, seq;
+  rtx note;
+  rtx_base_insn seq;
   rtx_base_insn tem;
   int probability;
-  rtx insn_last, insn;
+  rtx_base_insn insn_last, insn;
   int njumps = 0;
 
   /* We're not good at redistributing frame information.  */
diff --git a/gcc/except.c b/gcc/except.c
index bcd63cc..a07584d 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -210,7 +210,7 @@ action_record_hasher::equal (const value_type *entry, const compare_type *data)
 
 typedef hash_table <action_record_hasher> action_hash_type;
 
-static bool get_eh_region_and_lp_from_rtx (const_rtx, eh_region *,
+static bool get_eh_region_and_lp_from_rtx (const_rtx_base_insn, eh_region *,
 					   eh_landing_pad *);
 
 static int t2r_eq (const void *, const void *);
@@ -1723,7 +1723,7 @@ make_reg_eh_region_note_nothrow_nononlocal (rtx insn)
    to the contrary.  */
 
 bool
-insn_could_throw_p (const_rtx insn)
+insn_could_throw_p (const_rtx_base_insn insn)
 {
   if (!flag_exceptions)
     return false;
@@ -1739,9 +1739,10 @@ insn_could_throw_p (const_rtx insn)
    to look for a note, or the note itself.  */
 
 void
-copy_reg_eh_region_note_forward (rtx note_or_insn, rtx first, rtx last)
+copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_base_insn first, rtx last)
 {
-  rtx insn, note = note_or_insn;
+  rtx_base_insn insn;
+  rtx note = note_or_insn;
 
   if (INSN_P (note_or_insn))
     {
@@ -1760,9 +1761,11 @@ copy_reg_eh_region_note_forward (rtx note_or_insn, rtx first, rtx last)
 /* Likewise, but iterate backward.  */
 
 void
-copy_reg_eh_region_note_backward (rtx note_or_insn, rtx last, rtx first)
+copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_base_insn last,
+				  rtx first)
 {
-  rtx insn, note = note_or_insn;
+  rtx_base_insn insn;
+  rtx note = note_or_insn;
 
   if (INSN_P (note_or_insn))
     {
@@ -1782,7 +1785,7 @@ copy_reg_eh_region_note_backward (rtx note_or_insn, rtx last, rtx first)
    was marked NOTHROW.  */
 
 static bool
-get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region *pr,
+get_eh_region_and_lp_from_rtx (const_rtx_base_insn insn, eh_region *pr,
 			       eh_landing_pad *plp)
 {
   eh_landing_pad lp = NULL;
@@ -1796,7 +1799,7 @@ get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region *pr,
 
   if (NONJUMP_INSN_P (insn)
       && GET_CODE (PATTERN (insn)) == SEQUENCE)
-    insn = XVECEXP (PATTERN (insn), 0, 0);
+    insn = XVECEXP (PATTERN (insn), 0, 0)->as_an_rtx_base_insn ();
 
   note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
   if (!note)
@@ -1835,7 +1838,8 @@ get_eh_landing_pad_from_rtx (const_rtx insn)
   eh_landing_pad lp;
   eh_region r;
 
-  get_eh_region_and_lp_from_rtx (insn, &r, &lp);
+  get_eh_region_and_lp_from_rtx (insn->as_an_rtx_base_insn (), &r, &lp);
+  /* TODO: remove the above cast.  */
   return lp;
 }
 
@@ -1848,7 +1852,8 @@ get_eh_region_from_rtx (const_rtx insn)
   eh_landing_pad lp;
   eh_region r;
 
-  get_eh_region_and_lp_from_rtx (insn, &r, &lp);
+  get_eh_region_and_lp_from_rtx (insn->as_an_rtx_base_insn (), &r, &lp);
+  /* TODO: remove the above cast.  */
   return r;
 }
 
@@ -1885,7 +1890,9 @@ can_throw_external (const_rtx insn)
       return false;
     }
 
-  nothrow = get_eh_region_and_lp_from_rtx (insn, &r, &lp);
+  nothrow = get_eh_region_and_lp_from_rtx (insn->as_an_rtx_base_insn (), &r,
+					   &lp);
+  /* TODO: remove the above cast.  */
 
   /* If we can't throw, we obviously can't throw external.  */
   if (nothrow)
@@ -1929,7 +1936,8 @@ insn_nothrow_p (const_rtx insn)
       return true;
     }
 
-  return get_eh_region_and_lp_from_rtx (insn, &r, &lp);
+  return get_eh_region_and_lp_from_rtx (insn->as_an_rtx_base_insn (), &r, &lp);
+  /* TODO: remove the above cast.  */
 }
 
 /* Return true if INSN can perform a non-local goto.  */
@@ -2467,18 +2475,18 @@ add_call_site (rtx landing_pad, int action, int section)
 static unsigned int
 convert_to_eh_region_ranges (void)
 {
-  rtx insn, iter;
+  rtx_base_insn insn, iter;
   rtx_note note;
   action_hash_type ar_hash;
   int last_action = -3;
-  rtx last_action_insn = NULL_RTX;
+  rtx_base_insn last_action_insn = NULL_RTX_BASE_INSN;
   rtx last_landing_pad = NULL_RTX;
-  rtx first_no_action_insn = NULL_RTX;
+  rtx_base_insn first_no_action_insn = NULL_RTX_BASE_INSN;
   int call_site = 0;
   int cur_sec = 0;
-  rtx section_switch_note = NULL_RTX;
-  rtx first_no_action_insn_before_switch = NULL_RTX;
-  rtx last_no_action_insn_before_switch = NULL_RTX;
+  rtx_base_insn section_switch_note = NULL_RTX_BASE_INSN;
+  rtx_base_insn first_no_action_insn_before_switch = NULL_RTX_BASE_INSN;
+  rtx_base_insn last_no_action_insn_before_switch = NULL_RTX_BASE_INSN;
   int saved_call_site_base = call_site_base;
 
   vec_alloc (crtl->eh.action_record_data, 64);
@@ -2497,7 +2505,7 @@ convert_to_eh_region_ranges (void)
 	insn = iter;
 	if (NONJUMP_INSN_P (insn)
 	    && GET_CODE (PATTERN (insn)) == SEQUENCE)
-	  insn = XVECEXP (PATTERN (insn), 0, 0);
+	  insn = XVECEXP (PATTERN (insn), 0, 0)->as_an_rtx_base_insn ();
 
 	nothrow = get_eh_region_and_lp_from_rtx (insn, &region, &lp);
 	if (nothrow)
@@ -2547,8 +2555,8 @@ convert_to_eh_region_ranges (void)
 		gcc_assert (last_action != -3
 			    || (last_action_insn
 				== last_no_action_insn_before_switch));
-		first_no_action_insn_before_switch = NULL_RTX;
-		last_no_action_insn_before_switch = NULL_RTX;
+		first_no_action_insn_before_switch = NULL_RTX_BASE_INSN;
+		last_no_action_insn_before_switch = NULL_RTX_BASE_INSN;
 		call_site_base++;
 	      }
 	    /* If we'd not seen a previous action (-3) or the previous
@@ -2563,7 +2571,7 @@ convert_to_eh_region_ranges (void)
 		    note = emit_note_before (NOTE_INSN_EH_REGION_BEG,
 					     first_no_action_insn);
 		    NOTE_EH_HANDLER (note) = call_site;
-		    first_no_action_insn = NULL_RTX;
+		    first_no_action_insn = NULL_RTX_BASE_INSN;
 		  }
 
 		note = emit_note_after (NOTE_INSN_EH_REGION_END,
@@ -2597,7 +2605,7 @@ convert_to_eh_region_ranges (void)
 	  {
 	    first_no_action_insn_before_switch = first_no_action_insn;
 	    last_no_action_insn_before_switch = last_action_insn;
-	    first_no_action_insn = NULL_RTX;
+	    first_no_action_insn = NULL_RTX_BASE_INSN;
 	    gcc_assert (last_action == -1);
 	    last_action = -3;
 	  }
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 2b24f55..8fd3fa1 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -4537,7 +4537,7 @@ strip_paradoxical_subreg (rtx *op_ptr, rtx *other_ptr)
    annotate all that may trap.  */
 
 static void
-fixup_eh_region_note (rtx insn, rtx prev, rtx next)
+fixup_eh_region_note (rtx_base_insn insn, rtx prev, rtx next)
 {
   rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
   if (note == NULL)
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 9f3438d..fecd88a 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2432,11 +2432,11 @@ extern int may_trap_p (const_rtx);
 extern int may_trap_or_fault_p (const_rtx);
 extern bool can_throw_internal (const_rtx);
 extern bool can_throw_external (const_rtx);
-extern bool insn_could_throw_p (const_rtx);
+extern bool insn_could_throw_p (const_rtx_base_insn);
 extern bool insn_nothrow_p (const_rtx);
 extern bool can_nonlocal_goto (const_rtx);
-extern void copy_reg_eh_region_note_forward (rtx, rtx, rtx);
-extern void copy_reg_eh_region_note_backward (rtx, rtx, rtx);
+extern void copy_reg_eh_region_note_forward (rtx, rtx_base_insn, rtx);
+extern void copy_reg_eh_region_note_backward (rtx, rtx_base_insn, rtx);
 extern int inequality_comparisons_p (const_rtx);
 extern rtx replace_rtx (rtx, rtx, rtx);
 extern int replace_label (rtx *, void *);
-- 
1.7.11.7

