diff options
author | Greg Fischer <greg@lunarg.com> | 2022-07-08 20:11:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 20:11:22 +0300 |
commit | 69e1deabc1cdab0ec8e19cae8250236c0d22e689 (patch) | |
tree | d468b67467a0dd5cf533f261e6796c8fd856ddb6 | |
parent | bc5c8760af8375a0e92ee3318bda15ed9a165ef1 (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.cpp | 6 |
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); } |