Skip to content

Commit a060a9a

Browse files
krystian-andrzejewskiigcbot
authored andcommitted
Prevent from a double erasion of instructions in HoistCongruentPHI
This change is to avoid exception related to double erasion of instructions in `HoistCongruentPHI`.
1 parent 82a7975 commit a060a9a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

IGC/Compiler/CISACodeGen/HoistCongruentPhi.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,14 @@ bool HoistCongruentPHI::hoistCongruentPhi(PHINode *phi) {
301301
// below to not invalidate the `insertPos` that may also
302302
// be in the `instMap`
303303
}
304+
std::set<Instruction *> removed;
304305
for (auto &insts : instMap) {
305-
insts.first->eraseFromParent();
306-
insts.second->eraseFromParent();
306+
if (removed.insert(insts.first).second) {
307+
insts.first->eraseFromParent();
308+
}
309+
if (removed.insert(insts.second).second) {
310+
insts.second->eraseFromParent();
311+
}
307312
}
308313
changed = true;
309314
}

0 commit comments

Comments
 (0)