Only delete instructions once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138700 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp
index 1a8f6b9..7b0b34e 100644
--- a/lib/VMCore/AutoUpgrade.cpp
+++ b/lib/VMCore/AutoUpgrade.cpp
@@ -389,7 +389,7 @@
// This map stores the slots where the exception object and selector value are
// stored within a function.
- SmallVector<Instruction*, 32> DeadInsts;
+ SmallPtrSet<Instruction*, 32> DeadInsts;
DenseMap<Function*, std::pair<Value*, Value*> > FnToLPadSlotMap;
for (Module::iterator
I = M->begin(), E = M->end(); I != E; ++I) {
@@ -439,14 +439,15 @@
Exn->replaceAllUsesWith(LPExn);
Sel->replaceAllUsesWith(LPSel);
- DeadInsts.push_back(Exn);
- DeadInsts.push_back(Sel);
+ DeadInsts.insert(Exn);
+ DeadInsts.insert(Sel);
}
}
// Remove the dead instructions.
- while (!DeadInsts.empty()) {
- Instruction *Inst = DeadInsts.pop_back_val();
+ for (SmallPtrSet<Instruction*, 32>::iterator
+ I = DeadInsts.begin(), E = DeadInsts.end(); I != E; ++I) {
+ Instruction *Inst = *I;
Inst->eraseFromParent();
}