https://gcc.gnu.org/g:b850721e0447fa2b4d262ffce0f683611d388d84

commit r17-5849-gb850721e0447fa2b4d262ffce0f683611d388d84
Author: Trevor Saunders <[email protected]>
Date:   Sat Oct 24 08:54:08 2026 +0000

    Pass a const rtx_insn * to the EH throw helpers
    
    gcc/ChangeLog:
    
            * except.cc (insn_could_throw_p, get_eh_region_and_lp_from_rtx,
            get_eh_landing_pad_from_rtx, can_throw_internal, can_throw_external,
            insn_nothrow_p, convert_to_eh_region_ranges): Take a const rtx_insn 
*.
            * except.h (get_eh_landing_pad_from_rtx): Likewise.
            * rtl.h (can_throw_internal, can_throw_external, insn_could_throw_p,
            insn_nothrow_p): Likewise.
            * cse.cc (count_reg_usage): Likewise.
            * reorg.cc (relax_delay_slots): Likewise.

Diff:
---
 gcc/cse.cc    |  3 ++-
 gcc/except.cc | 22 +++++++++++-----------
 gcc/except.h  |  2 +-
 gcc/reorg.cc  |  2 +-
 gcc/rtl.h     |  8 ++++----
 5 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/gcc/cse.cc b/gcc/cse.cc
index 230f4706a8ea..53483b967edb 100644
--- a/gcc/cse.cc
+++ b/gcc/cse.cc
@@ -7155,7 +7155,8 @@ count_reg_usage (rtx x, int *counts, rtx dest, int incr)
       /* We expect dest to be NULL_RTX here.  If the insn may throw,
         or if it cannot be deleted due to side-effects, mark this fact
         by setting DEST to pc_rtx.  */
-      if ((!cfun->can_delete_dead_exceptions && !insn_nothrow_p (x))
+      if ((!cfun->can_delete_dead_exceptions
+          && !insn_nothrow_p (as_a <rtx_insn *> (x)))
          || side_effects_p (PATTERN (x)))
        dest = pc_rtx;
       if (code == CALL_INSN)
diff --git a/gcc/except.cc b/gcc/except.cc
index 0a15d7471625..1a7ff2b21ced 100644
--- a/gcc/except.cc
+++ b/gcc/except.cc
@@ -209,7 +209,7 @@ action_record_hasher::equal (const action_record *entry,
 
 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_insn *, eh_region *,
                                           eh_landing_pad *);
 
 static void dw2_build_landing_pads (void);
@@ -1752,7 +1752,7 @@ make_reg_eh_region_note_nothrow_nononlocal (rtx_insn 
*insn)
    to the contrary.  */
 
 bool
-insn_could_throw_p (const_rtx insn)
+insn_could_throw_p (const rtx_insn *insn)
 {
   if (!flag_exceptions)
     return false;
@@ -1817,7 +1817,7 @@ copy_reg_eh_region_note_backward (rtx note_or_insn, 
rtx_insn *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_insn *insn, eh_region *pr,
                               eh_landing_pad *plp)
 {
   rtx note;
@@ -1855,7 +1855,7 @@ get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region 
*pr,
    have a reachable landing pad within this function.  */
 
 eh_landing_pad
-get_eh_landing_pad_from_rtx (const_rtx insn)
+get_eh_landing_pad_from_rtx (const rtx_insn *insn)
 {
   eh_landing_pad lp;
   eh_region r;
@@ -1880,7 +1880,7 @@ get_eh_region_from_rtx (const rtx_insn *insn)
 /* Return true if INSN throws and is caught by something in this function.  */
 
 bool
-can_throw_internal (const_rtx insn)
+can_throw_internal (const rtx_insn *insn)
 {
   return get_eh_landing_pad_from_rtx (insn) != NULL;
 }
@@ -1888,7 +1888,7 @@ can_throw_internal (const_rtx insn)
 /* Return true if INSN throws and escapes from the current function.  */
 
 bool
-can_throw_external (const_rtx insn)
+can_throw_external (const rtx_insn *insn)
 {
   eh_landing_pad lp;
   eh_region r;
@@ -1903,7 +1903,7 @@ can_throw_external (const_rtx insn)
       int i, n = seq->len ();
 
       for (i = 0; i < n; i++)
-       if (can_throw_external (seq->element (i)))
+       if (can_throw_external (seq->insn (i)))
          return true;
 
       return false;
@@ -1932,7 +1932,7 @@ can_throw_external (const_rtx insn)
 /* Return true if INSN cannot throw at all.  */
 
 bool
-insn_nothrow_p (const_rtx insn)
+insn_nothrow_p (const rtx_insn *insn)
 {
   eh_landing_pad lp;
   eh_region r;
@@ -1946,7 +1946,7 @@ insn_nothrow_p (const_rtx insn)
       int i, n = seq->len ();
 
       for (i = 0; i < n; i++)
-       if (!insn_nothrow_p (seq->element (i)))
+       if (!insn_nothrow_p (seq->insn (i)))
          return false;
 
       return true;
@@ -2569,7 +2569,7 @@ maybe_add_nop_after_section_switch (void)
 static unsigned int
 convert_to_eh_region_ranges (void)
 {
-  rtx insn;
+  rtx_insn *insn;
   rtx_insn *iter;
   rtx_note *note;
   action_hash_type ar_hash (31);
@@ -2598,7 +2598,7 @@ convert_to_eh_region_ranges (void)
        insn = iter;
        rtx_sequence *seq = dyn_cast<rtx_sequence *> (PATTERN (insn));
        if (NONJUMP_INSN_P (insn) && seq)
-         insn = seq->element (0);
+         insn = seq->insn (0);
 
        nothrow = get_eh_region_and_lp_from_rtx (insn, &region, &lp);
        if (nothrow)
diff --git a/gcc/except.h b/gcc/except.h
index 2757be9571a9..f0e89fa15dcb 100644
--- a/gcc/except.h
+++ b/gcc/except.h
@@ -279,7 +279,7 @@ extern tree lookup_type_for_runtime (tree);
 extern void assign_filter_values (void);
 
 extern eh_region get_eh_region_from_rtx (const rtx_insn *);
-extern eh_landing_pad get_eh_landing_pad_from_rtx (const_rtx);
+extern eh_landing_pad get_eh_landing_pad_from_rtx (const rtx_insn *);
 
 extern void finish_eh_generation (void);
 
diff --git a/gcc/reorg.cc b/gcc/reorg.cc
index 22d23746d110..1b6870b69f60 100644
--- a/gcc/reorg.cc
+++ b/gcc/reorg.cc
@@ -3285,7 +3285,7 @@ relax_delay_slots (rtx_insn *first)
       trial = next_real_nondebug_insn (as_a<rtx_insn *> (target_label));
       if (trial && GET_CODE (PATTERN (trial)) != SEQUENCE
          && redundant_insn (trial, insn, vNULL)
-         && ! can_throw_internal (trial))
+         && ! can_throw_internal (as_a <rtx_insn *> (trial)))
        {
          /* Figure out where to emit the special USE insn so we don't
             later incorrectly compute register live/death info.  */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 1f389b149b34..015d3742c224 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3783,10 +3783,10 @@ extern bool volatile_insn_p (const_rtx);
 extern bool may_trap_p_1 (const_rtx, unsigned);
 extern bool may_trap_p (const_rtx);
 extern bool 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_nothrow_p (const_rtx);
+extern bool can_throw_internal (const rtx_insn *);
+extern bool can_throw_external (const rtx_insn *);
+extern bool insn_could_throw_p (const rtx_insn *);
+extern bool insn_nothrow_p (const rtx_insn *);
 extern bool can_nonlocal_goto (const rtx_insn *);
 extern void copy_reg_eh_region_note_forward (rtx, rtx_insn *, rtx);
 extern void copy_reg_eh_region_note_backward (rtx, rtx_insn *, rtx);

Reply via email to