From 05fab97b2ce8ebd8420ded175101a0fa5110172c Mon Sep 17 00:00:00 2001 From: Gert Wollny <gert.wollny@collabora.com> Date: Tue, 20 Dec 2022 15:22:40 +0100 Subject: [PATCH] r600/sfn: Don't try to re-use the iterator when uses is updated It seems on libc++ the iterator is invalidated when an element is removed from the set, so make sure that we don't implicitely use the old, invalidated iterator in the range based - open code the loop using while instead. Fixes: f3415c (r600/sfn: copy propagate register load chains) Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7931 Signed-off-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20394> --- src/gallium/drivers/r600/sfn/sfn_optimizer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp index 31b43069877d3..db0dde7a20602 100644 --- a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp @@ -360,7 +360,12 @@ CopyPropFwdVisitor::visit(AluInstr *instr) auto src = instr->psrc(0); auto dest = instr->dest(); - for (auto& i : dest->uses()) { + auto ii = dest->uses().begin(); + auto ie = dest->uses().end(); + + while(ii != ie) { + auto i = *ii; + ++ii; /* SSA can always be propagated, registers only in the same block * and only if they are assigned in the same block */ bool can_propagate = dest->has_flag(Register::ssa); -- GitLab