Skip to content

Commit 2b7fe90

Browse files
authored
llvm-reduce: Avoid worklist in simplify-instruction (#134066)
1 parent e6c2fdc commit 2b7fe90

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,20 @@ using namespace llvm;
2020
/// Calls simplifyInstruction in each instruction in functions, and replaces
2121
/// their values.
2222
void llvm::simplifyInstructionsDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
23-
std::vector<Instruction *> InstsToDelete;
24-
2523
Module &Program = WorkItem.getModule();
2624
const DataLayout &DL = Program.getDataLayout();
2725

28-
std::vector<Instruction *> InstToDelete;
2926
for (auto &F : Program) {
3027
for (auto &BB : F) {
31-
for (auto &Inst : BB) {
32-
28+
for (auto &Inst : make_early_inc_range(BB)) {
3329
SimplifyQuery Q(DL, &Inst);
3430
if (Value *Simplified = simplifyInstruction(&Inst, Q)) {
3531
if (O.shouldKeep())
3632
continue;
3733
Inst.replaceAllUsesWith(Simplified);
38-
InstToDelete.push_back(&Inst);
34+
Inst.eraseFromParent();
3935
}
4036
}
4137
}
4238
}
43-
44-
for (Instruction *I : InstToDelete)
45-
I->eraseFromParent();
4639
}

0 commit comments

Comments
 (0)