https://gcc.gnu.org/g:6d9a79665c609db8fc9a6a444234a1afeb58ea42
commit r17-5866-g6d9a79665c609db8fc9a6a444234a1afeb58ea42 Author: Trevor Saunders <[email protected]> Date: Wed Oct 28 04:05:51 2026 +0000 Pass a const rtx_insn * to the reg-note finders gcc/ChangeLog: * rtl.h (find_reg_note, find_regno_note, find_reg_fusage, find_regno_fusage): Take a const rtx_insn *. * rtlanal.cc (find_reg_note, find_regno_note, find_reg_fusage, find_regno_fusage): Likewise. (reg_set_p): Pass a const rtx_insn *. * sched-deps.cc (mark_insn_reg_store): Likewise. * except.cc (copy_reg_eh_region_note_forward, copy_reg_eh_region_note_backward): Likewise. * resource.cc (mark_referenced_resources): Likewise. Diff: --- gcc/except.cc | 24 ++++++++++++------------ gcc/resource.cc | 9 +++++---- gcc/rtl.h | 8 ++++---- gcc/rtlanal.cc | 16 ++++++++++------ gcc/sched-deps.cc | 2 +- 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/gcc/except.cc b/gcc/except.cc index d00f033af514..e97e13626c43 100644 --- a/gcc/except.cc +++ b/gcc/except.cc @@ -1771,20 +1771,20 @@ void copy_reg_eh_region_note_forward (rtx note_or_insn, rtx_insn *first, rtx_insn *last) { - rtx_insn *insn; rtx note = note_or_insn; - if (INSN_P (note_or_insn)) + if (rtx_insn *insn = dyn_cast <rtx_insn *> (note_or_insn)) { - note = find_reg_note (note_or_insn, REG_EH_REGION, NULL_RTX); + if (!INSN_P (insn)) + return; + + note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); if (note == NULL) return; } - else if (is_a <rtx_insn *> (note_or_insn)) - return; note = XEXP (note, 0); - for (insn = first; insn != last ; insn = NEXT_INSN (insn)) + for (rtx_insn *insn = first; insn != last ; insn = NEXT_INSN (insn)) if (!find_reg_note (insn, REG_EH_REGION, NULL_RTX) && insn_could_throw_p (insn)) add_reg_note (insn, REG_EH_REGION, note); @@ -1796,20 +1796,20 @@ void copy_reg_eh_region_note_backward (rtx note_or_insn, rtx_insn *last, rtx_insn *first) { - rtx_insn *insn; rtx note = note_or_insn; - if (INSN_P (note_or_insn)) + if (rtx_insn *insn = dyn_cast <rtx_insn *> (note_or_insn)) { - note = find_reg_note (note_or_insn, REG_EH_REGION, NULL_RTX); + if (!INSN_P (insn)) + return; + + note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); if (note == NULL) return; } - else if (is_a <rtx_insn *> (note_or_insn)) - return; note = XEXP (note, 0); - for (insn = last; insn != first; insn = PREV_INSN (insn)) + for (rtx_insn *insn = last; insn != first; insn = PREV_INSN (insn)) if (insn_could_throw_p (insn)) add_reg_note (insn, REG_EH_REGION, note); } diff --git a/gcc/resource.cc b/gcc/resource.cc index d5e52ec9c220..f377fe99e513 100644 --- a/gcc/resource.cc +++ b/gcc/resource.cc @@ -299,13 +299,14 @@ mark_referenced_resources (rtx x, struct resources *res, However, we may have moved some of the parameter loading insns into the delay slot of this CALL. If so, the USE's for them don't count and should be skipped. */ - rtx_insn *insn = PREV_INSN (as_a <rtx_insn *> (x)); + rtx_insn *call_insn = as_a <rtx_insn *> (x); + rtx_insn *insn = PREV_INSN (call_insn); rtx_sequence *sequence = 0; int seq_size = 0; int i; /* If we are part of a delay slot sequence, point at the SEQUENCE. */ - if (NEXT_INSN (insn) != x) + if (NEXT_INSN (insn) != call_insn) { sequence = as_a <rtx_sequence *> (PATTERN (NEXT_INSN (insn))); seq_size = sequence->len (); @@ -333,13 +334,13 @@ mark_referenced_resources (rtx x, struct resources *res, registers ensures that a register will not be considered dead just because it crosses a setjmp call. A register should be considered dead only if the setjmp call returns nonzero. */ - if (find_reg_note (x, REG_SETJMP, NULL)) + if (find_reg_note (call_insn, REG_SETJMP, NULL)) SET_HARD_REG_SET (res->regs); { rtx link; - for (link = CALL_INSN_FUNCTION_USAGE (x); + for (link = CALL_INSN_FUNCTION_USAGE (call_insn); link; link = XEXP (link, 1)) if (GET_CODE (XEXP (link, 0)) == USE) diff --git a/gcc/rtl.h b/gcc/rtl.h index 24727a683557..0efdc50ee0e7 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3762,12 +3762,12 @@ extern void note_stores (const rtx_insn *, extern void note_uses (rtx *, void (*) (rtx *, void *), void *); extern bool dead_or_set_p (const rtx_insn *, const_rtx); extern bool dead_or_set_regno_p (const rtx_insn *, unsigned int); -extern rtx find_reg_note (const_rtx, enum reg_note, const_rtx); -extern rtx find_regno_note (const_rtx, enum reg_note, unsigned int); +extern rtx find_reg_note (const rtx_insn *, enum reg_note, const_rtx); +extern rtx find_regno_note (const rtx_insn *, enum reg_note, unsigned int); extern rtx find_reg_equal_equiv_note (const rtx_insn *); extern rtx find_constant_src (const rtx_insn *); -extern bool find_reg_fusage (const_rtx, enum rtx_code, const_rtx); -extern bool find_regno_fusage (const_rtx, enum rtx_code, unsigned int); +extern bool find_reg_fusage (const rtx_insn *, enum rtx_code, const_rtx); +extern bool find_regno_fusage (const rtx_insn *, enum rtx_code, unsigned int); extern rtx alloc_reg_note (enum reg_note, rtx, rtx); extern void add_reg_note (rtx_insn *, enum reg_note, rtx); extern void add_int_reg_note (rtx_insn *, enum reg_note, int); diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index 24fcbbea555b..b446c884aaf6 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -1235,8 +1235,12 @@ reg_set_between_p (const_rtx reg, const rtx_insn *from_insn, /* Return true if REG is set or clobbered inside INSN. */ bool -reg_set_p (const_rtx reg, const_rtx insn) +reg_set_p (const_rtx reg, const_rtx uncast_insn) { + const rtx_insn *insn = dyn_cast <const rtx_insn *> (uncast_insn); + if (!insn) + return set_of (reg, uncast_insn) != NULL_RTX; + /* After delay slot handling, call and branch insns might be in a sequence. Check all the elements there. */ if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE) @@ -1255,7 +1259,7 @@ reg_set_p (const_rtx reg, const_rtx insn) || (CALL_P (insn) && ((REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER - && (insn_callee_abi (as_a<const rtx_insn *> (insn)) + && (insn_callee_abi (insn) .clobbers_reg_p (GET_MODE (reg), REGNO (reg)))) || MEM_P (reg) || find_reg_fusage (insn, CLOBBER, reg))))) @@ -2518,7 +2522,7 @@ dead_or_set_regno_p (const rtx_insn *insn, unsigned int test_regno) If DATUM is nonzero, look for one whose datum is DATUM. */ rtx -find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum) +find_reg_note (const rtx_insn *insn, enum reg_note kind, const_rtx datum) { rtx link; @@ -2547,7 +2551,7 @@ find_reg_note (const_rtx insn, enum reg_note kind, const_rtx datum) it might be the case that the note overlaps REGNO. */ rtx -find_regno_note (const_rtx insn, enum reg_note kind, unsigned int regno) +find_regno_note (const rtx_insn *insn, enum reg_note kind, unsigned int regno) { rtx link; @@ -2623,7 +2627,7 @@ find_constant_src (const rtx_insn *insn) in the CALL_INSN_FUNCTION_USAGE information of INSN. */ bool -find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum) +find_reg_fusage (const rtx_insn *insn, enum rtx_code code, const_rtx datum) { /* If it's not a CALL_INSN, it can't possibly have a CALL_INSN_FUNCTION_USAGE field, so don't bother checking. */ @@ -2668,7 +2672,7 @@ find_reg_fusage (const_rtx insn, enum rtx_code code, const_rtx datum) in the CALL_INSN_FUNCTION_USAGE information of INSN. */ bool -find_regno_fusage (const_rtx insn, enum rtx_code code, unsigned int regno) +find_regno_fusage (const rtx_insn *insn, enum rtx_code code, unsigned int regno) { rtx link; diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index dfb99109df4d..5b8001f64ee8 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -2173,7 +2173,7 @@ mark_insn_reg_store (rtx reg, const_rtx setter, void *data) return; mark_insn_reg_birth ((rtx_insn *) data, reg, false, - find_reg_note ((const_rtx) data, REG_UNUSED, reg) != NULL_RTX); + find_reg_note ((const rtx_insn *) data, REG_UNUSED, reg) != NULL_RTX); } /* Like mark_insn_reg_store except notice just CLOBBERs; ignore SETs. */
