From cd2b4c319aa49f9e995ae7825393a661e40b6e64 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 11 May 2022 15:10:22 +0100 Subject: [PATCH] aco/ra: fix usage of invalidated iterator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Fixes: 58bd9a379ef ("aco/ra: fix live-range splits of phi definitions") Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 5cd29286e73..b9ed0c77371 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2120,7 +2120,10 @@ get_regs_for_phis(ra_ctx& ctx, Block& block, RegisterFile& register_file, } /* find registers for phis where the register was blocked or no operand was assigned */ - for (aco_ptr& phi : instructions) { + + /* Don't use iterators because get_reg_phi() can add phis to the end of the vector. */ + for (unsigned i = 0; i < instructions.size(); i++) { + aco_ptr& phi = instructions[i]; Definition& definition = phi->definitions[0]; if (definition.isFixed()) continue;