llvm-reduce: Avoid worklist in simplify-instruction (#134066)
diff --git a/llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp b/llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp
index 7eb381d..ee92b7f 100644
--- a/llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp
+++ b/llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp
@@ -20,27 +20,20 @@
/// Calls simplifyInstruction in each instruction in functions, and replaces
/// their values.
void llvm::simplifyInstructionsDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
- std::vector<Instruction *> InstsToDelete;
-
Module &Program = WorkItem.getModule();
const DataLayout &DL = Program.getDataLayout();
- std::vector<Instruction *> InstToDelete;
for (auto &F : Program) {
for (auto &BB : F) {
- for (auto &Inst : BB) {
-
+ for (auto &Inst : make_early_inc_range(BB)) {
SimplifyQuery Q(DL, &Inst);
if (Value *Simplified = simplifyInstruction(&Inst, Q)) {
if (O.shouldKeep())
continue;
Inst.replaceAllUsesWith(Simplified);
- InstToDelete.push_back(&Inst);
+ Inst.eraseFromParent();
}
}
}
}
-
- for (Instruction *I : InstToDelete)
- I->eraseFromParent();
}