Skip to content

Commit 85f3d60

Browse files
[Utils] Use range-based for loops (NFC) (#139426)
1 parent 8f31c6d commit 85f3d60

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ bool llvm::DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI,
168168
SmallVector<WeakTrackingVH, 8> PHIs(llvm::make_pointer_range(BB->phis()));
169169

170170
bool Changed = false;
171-
for (unsigned i = 0, e = PHIs.size(); i != e; ++i)
172-
if (PHINode *PN = dyn_cast_or_null<PHINode>(PHIs[i].operator Value*()))
171+
for (const auto &PHI : PHIs)
172+
if (PHINode *PN = dyn_cast_or_null<PHINode>(PHI.operator Value *()))
173173
Changed |= RecursivelyDeleteDeadPHINode(PN, TLI, MSSAU);
174174

175175
return Changed;

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,10 @@ void PromoteMem2Reg::run() {
931931
// hasn't traversed. If this is the case, the PHI nodes may not
932932
// have incoming values for all predecessors. Loop over all PHI nodes we have
933933
// created, inserting poison values if they are missing any incoming values.
934-
for (DenseMap<std::pair<unsigned, unsigned>, PHINode *>::iterator
935-
I = NewPhiNodes.begin(),
936-
E = NewPhiNodes.end();
937-
I != E; ++I) {
934+
for (const auto &PhiNode : NewPhiNodes) {
938935
// We want to do this once per basic block. As such, only process a block
939936
// when we find the PHI that is the first entry in the block.
940-
PHINode *SomePHI = I->second;
937+
PHINode *SomePHI = PhiNode.second;
941938
BasicBlock *BB = SomePHI->getParent();
942939
if (&BB->front() != SomePHI)
943940
continue;

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7080,8 +7080,8 @@ static bool switchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
70807080
APInt One(TableSizePowOf2, 1);
70817081
// Build bitmask; fill in a 1 bit for every case.
70827082
const ResultListTy &ResultList = ResultLists[PHIs[0]];
7083-
for (size_t I = 0, E = ResultList.size(); I != E; ++I) {
7084-
uint64_t Idx = (ResultList[I].first->getValue() - TableIndexOffset->getValue())
7083+
for (const auto &Result : ResultList) {
7084+
uint64_t Idx = (Result.first->getValue() - TableIndexOffset->getValue())
70857085
.getLimitedValue();
70867086
MaskInt |= One << Idx;
70877087
}

0 commit comments

Comments
 (0)