Skip to content

Commit 4570a34

Browse files
[CodeGen] Use range-based for loops (NFC) (#98459)
1 parent 6479a5a commit 4570a34

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

llvm/lib/CodeGen/AllocationOrder.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ AllocationOrder AllocationOrder::create(unsigned VirtReg, const VirtRegMap &VRM,
3939
LLVM_DEBUG({
4040
if (!Hints.empty()) {
4141
dbgs() << "hints:";
42-
for (unsigned I = 0, E = Hints.size(); I != E; ++I)
43-
dbgs() << ' ' << printReg(Hints[I], TRI);
42+
for (MCPhysReg Hint : Hints)
43+
dbgs() << ' ' << printReg(Hint, TRI);
4444
dbgs() << '\n';
4545
}
4646
});
47-
#ifndef NDEBUG
48-
for (unsigned I = 0, E = Hints.size(); I != E; ++I)
49-
assert(is_contained(Order, Hints[I]) &&
50-
"Target hint is outside allocation order.");
51-
#endif
47+
assert(all_of(Hints,
48+
[&](MCPhysReg Hint) { return is_contained(Order, Hint); }) &&
49+
"Target hint is outside allocation order.");
5250
return AllocationOrder(std::move(Hints), Order, HardHints);
5351
}

llvm/lib/CodeGen/MachineBasicBlock.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,10 +1484,9 @@ void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
14841484

14851485
// Scan the operands of this machine instruction, replacing any uses of Old
14861486
// with New.
1487-
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
1488-
if (I->getOperand(i).isMBB() &&
1489-
I->getOperand(i).getMBB() == Old)
1490-
I->getOperand(i).setMBB(New);
1487+
for (MachineOperand &MO : I->operands())
1488+
if (MO.isMBB() && MO.getMBB() == Old)
1489+
MO.setMBB(New);
14911490
}
14921491

14931492
// Update the successor information.

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,11 @@ void ScheduleDAGFast::ListScheduleBottomUp() {
622622
}
623623

624624
// Add the nodes that aren't ready back onto the available list.
625-
for (unsigned i = 0, e = NotReady.size(); i != e; ++i) {
626-
NotReady[i]->isPending = false;
625+
for (SUnit *SU : NotReady) {
626+
SU->isPending = false;
627627
// May no longer be available due to backtracking.
628-
if (NotReady[i]->isAvailable)
629-
AvailableQueue.push(NotReady[i]);
628+
if (SU->isAvailable)
629+
AvailableQueue.push(SU);
630630
}
631631
NotReady.clear();
632632

0 commit comments

Comments
 (0)