https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92410
--- Comment #5 from Matthew Malcomson <matmal01 at gcc dot gnu.org> --- I've had a little look into it, and the below seems promising: Based on a comment in haifa-sched.c, notes are removed before scheduling and added back in. Since the insn that is larger than the df buffer is a note, and I saw in gdb that it's added during `reemit_notes`, I figure the root problem might be that the notes are removed, then the df->insns array is calculated, then notes are added back in. I hence tested the below patch, and the testcase that Martin found no longer crashes. I have not yet looked into whether `df_recompute_luids` is the correct function to call or if there's a better approach. Just sharing an update. diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index 41cf1f3..564a358 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -6231,6 +6231,7 @@ commit_schedule (rtx_insn *prev_head, rtx_insn *tail, basic_block *target_bb) reemit_notes (insn); last_scheduled_insn = insn; } + df_recompute_luids(*target_bb); scheduled_insns.truncate (0); } diff --git a/gcc/regstat.c b/gcc/regstat.c index 4da9b7c..c6cefb11 100644 --- a/gcc/regstat.c +++ b/gcc/regstat.c @@ -324,6 +324,7 @@ regstat_bb_compute_calls_crossed (unsigned int bb_index, bitmap live) FOR_BB_INSNS_REVERSE (bb, insn) { + gcc_assert (INSN_UID (insn) < DF_INSN_SIZE ()); struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn); unsigned int regno; diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 8a1d414..5d8eeee 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -4673,6 +4673,7 @@ sel_restore_notes (void) if (NONDEBUG_INSN_P (insn)) reemit_notes (insn); + df_recompute_luids (first); first = first->next_bb; } while (first != last);