[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 Alex Coplan changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #6 from Alex Coplan --- Should be fixed, thanks for the report.
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 --- Comment #5 from GCC Commits --- The master branch has been updated by Alex Coplan : https://gcc.gnu.org/g:d41a1873f334cf29b9a595bb03c27bff2be17319 commit r14-8496-gd41a1873f334cf29b9a595bb03c27bff2be17319 Author: Alex Coplan Date: Mon Jan 29 13:28:04 2024 + aarch64: Ensure iterator validity when updating debug uses [PR113616] The fix for PR113089 introduced range-based for loops over the debug_insn_uses of an RTL-SSA set_info, but in the case that we reset a debug insn, the use would get removed from the use list, and thus we would end up using an invalidated iterator in the next iteration of the loop. In practice this means we end up terminating the loop prematurely, and hence ICE as in PR113089 since there are debug uses that we failed to fix up. This patch fixes that by introducing a general mechanism to avoid this sort of problem. We introduce a safe_iterator to iterator-utils.h which wraps an iterator, and also holds the end iterator value. It then pre-computes the next iterator value at all iterations, so it doesn't matter if the original iterator got invalidated during the loop body, we can still move safely to the next iteration. We introduce an iterate_safely helper which effectively adapts a container such as iterator_range into a container of safe_iterators over the original iterator type. We then use iterate_safely around all loops over debug_insn_uses () in the aarch64 ldp/stp pass to fix PR113616. While doing this, I remembered that cleanup_tombstones () had the same problem. I previously worked around this locally by manually maintaining the next nondebug insn, so this patch also refactors that loop to use the new iterate_safely helper. While doing that I noticed that a couple of cases in cleanup_tombstones could be converted from using dyn_cast to as_a, which should be safe because there are no clobbers of mem in RTL-SSA, so all defs of memory should be set_infos. gcc/ChangeLog: PR target/113616 * config/aarch64/aarch64-ldp-fusion.cc (fixup_debug_uses_trailing_add): Use iterate_safely when iterating over debug uses. (fixup_debug_uses): Likewise. (ldp_bb_info::cleanup_tombstones): Use iterate_safely to iterate over nondebug insns instead of manually maintaining the next insn. * iterator-utils.h (class safe_iterator): New. (iterate_safely): New. gcc/testsuite/ChangeLog: PR target/113616 * gcc.c-torture/compile/pr113616.c: New test.
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 Alex Coplan changed: What|Removed |Added URL||https://gcc.gnu.org/piperma ||il/gcc-patches/2024-January ||/644167.html Keywords||patch --- Comment #4 from Alex Coplan --- Patch submitted: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/644167.html
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 --- Comment #3 from Alex Coplan --- Testing a patch.
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 --- Comment #2 from Alex Coplan --- 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.
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 Alex Coplan changed: What|Removed |Added Keywords||ice-on-valid-code Last reconfirmed||2024-01-26 Known to fail||14.0 Ever confirmed|0 |1 See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=113089 Target||aarch64-*-* Assignee|unassigned at gcc dot gnu.org |acoplan at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Alex Coplan --- Confirmed, mine.
[Bug target/113616] [14 Regression] ICE in process_uses_of_deleted_def, at rtl-ssa/changes.cc:252
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113616 Jakub Jelinek changed: What|Removed |Added CC||acoplan at gcc dot gnu.org Target Milestone|--- |14.0 Priority|P3 |P1