Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Fischer <greg@lunarg.com>2022-07-08 20:11:22 +0300
committerGitHub <noreply@github.com>2022-07-08 20:11:22 +0300
commit69e1deabc1cdab0ec8e19cae8250236c0d22e689 (patch)
treed468b67467a0dd5cf533f261e6796c8fd856ddb6
parentbc5c8760af8375a0e92ee3318bda15ed9a165ef1 (diff)
Fix small bug traversing users in interface_var_sroa (#4850)
Fix code that is traversing def-use user structure at the same time that it is changing it. This is dicey at best and error prone at worst. This was uncovered making a change to the id_to_user representation.
-rw-r--r--source/opt/interface_var_sroa.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/opt/interface_var_sroa.cpp b/source/opt/interface_var_sroa.cpp
index 58ed897c1..1b2cb3636 100644
--- a/source/opt/interface_var_sroa.cpp
+++ b/source/opt/interface_var_sroa.cpp
@@ -212,8 +212,12 @@ void InterfaceVariableScalarReplacement::KillInstructionAndUsers(
context()->KillInst(inst);
return;
}
+ std::vector<Instruction*> users;
context()->get_def_use_mgr()->ForEachUser(
- inst, [this](Instruction* user) { KillInstructionAndUsers(user); });
+ inst, [&users](Instruction* user) { users.push_back(user); });
+ for (auto user : users) {
+ context()->KillInst(user);
+ }
context()->KillInst(inst);
}