Skip to content

Commit 9d984b1

Browse files
committed
Don't use make_early_inc_range where not needed and move UniqueSuccessors to an outer scope
1 parent 3bce2c0 commit 9d984b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ emptyAndDetachBlock(BasicBlock *BB,
9595
void llvm::detachDeadBlocks(ArrayRef<BasicBlock *> BBs,
9696
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
9797
bool KeepOneInputPHIs) {
98+
SmallPtrSet<BasicBlock *, 4> UniqueEHRetBlocksToDelete;
9899
for (auto *BB : BBs) {
99100
auto NonFirstPhiIt = BB->getFirstNonPHIIt();
100101
if (NonFirstPhiIt != BB->end()) {
@@ -106,7 +107,8 @@ void llvm::detachDeadBlocks(ArrayRef<BasicBlock *> BBs,
106107
// first block, the we would have possible cleanupret and catchret
107108
// instructions with poison arguments, which wouldn't be valid.
108109
if (isa<FuncletPadInst>(I)) {
109-
SmallPtrSet<BasicBlock *, 4> UniqueEHRetBlocksToDelete;
110+
UniqueEHRetBlocksToDelete.clear();
111+
110112
for (User *User : I.users()) {
111113
Instruction *ReturnInstr = dyn_cast<Instruction>(User);
112114
// If we have a cleanupret or catchret block, replace it with just an
@@ -118,12 +120,14 @@ void llvm::detachDeadBlocks(ArrayRef<BasicBlock *> BBs,
118120
UniqueEHRetBlocksToDelete.insert(ReturnInstrBB);
119121
}
120122
}
121-
for (BasicBlock *EHRetBB :
122-
make_early_inc_range(UniqueEHRetBlocksToDelete))
123+
124+
for (BasicBlock *EHRetBB : UniqueEHRetBlocksToDelete)
123125
emptyAndDetachBlock(EHRetBB, Updates, KeepOneInputPHIs);
124126
}
125127
}
126128

129+
UniqueEHRetBlocksToDelete.clear();
130+
127131
// Detaching and emptying the current basic block.
128132
emptyAndDetachBlock(BB, Updates, KeepOneInputPHIs);
129133
}

0 commit comments

Comments
 (0)