Mesa (main): aco/ra: fix usage of invalidated iterator

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 30 17:02:26 UTC 2022


Module: Mesa
Branch: main
Commit: cd2b4c319aa49f9e995ae7825393a661e40b6e64
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd2b4c319aa49f9e995ae7825393a661e40b6e64

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed May 11 15:10:22 2022 +0100

aco/ra: fix usage of invalidated iterator

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 58bd9a379ef ("aco/ra: fix live-range splits of phi definitions")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16454>

---

 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<Instruction>& 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<Instruction>& phi = instructions[i];
       Definition& definition = phi->definitions[0];
       if (definition.isFixed())
          continue;



More information about the mesa-commit mailing list