https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616
--- Comment #2 from Alex Coplan <acoplan at gcc dot gnu.org> --- I think the problem is this loop (and others that iterate over debug uses in this way): // Now that we've characterized the defs involved, go through the // debug uses and determine how to update them (if needed). for (auto use : set->debug_insn_uses ()) { if (*pair_dst < *use->insn () && defs[1]) // We're re-ordering defs[1] above a previous use of the // same resource. update_debug_use (use, defs[1], writeback_pats[1]); else if (*pair_dst >= *use->insn ()) // We're re-ordering defs[0] below its use. update_debug_use (use, defs[0], writeback_pats[0]); } because `update_debug_use` can remove uses from the list of debug uses, we can't use a for-range loop as the iterator will become invalidated before getting advanced. Should be fairly straightforward to fix, sorry for the oversight.