[llvm] [CodeGen] Use range-based for loops (NFC) (PR #98459)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 03:58:35 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/98459
None
>From a9279cb209274f7d22f418f75c2461d94bb3094a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 10 Jul 2024 16:25:11 -0700
Subject: [PATCH] [CodeGen] Use range-based for loops (NFC)
---
llvm/lib/CodeGen/AllocationOrder.cpp | 8 ++++----
llvm/lib/CodeGen/MachineBasicBlock.cpp | 7 +++----
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp | 8 ++++----
3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/llvm/lib/CodeGen/AllocationOrder.cpp b/llvm/lib/CodeGen/AllocationOrder.cpp
index 2aef1234ac0ed..256274e014aec 100644
--- a/llvm/lib/CodeGen/AllocationOrder.cpp
+++ b/llvm/lib/CodeGen/AllocationOrder.cpp
@@ -39,14 +39,14 @@ AllocationOrder AllocationOrder::create(unsigned VirtReg, const VirtRegMap &VRM,
LLVM_DEBUG({
if (!Hints.empty()) {
dbgs() << "hints:";
- for (unsigned I = 0, E = Hints.size(); I != E; ++I)
- dbgs() << ' ' << printReg(Hints[I], TRI);
+ for (MCPhysReg Hint : Hints)
+ dbgs() << ' ' << printReg(Hint, TRI);
dbgs() << '\n';
}
});
#ifndef NDEBUG
- for (unsigned I = 0, E = Hints.size(); I != E; ++I)
- assert(is_contained(Order, Hints[I]) &&
+ for (MCPhysReg Hint : Hints)
+ assert(is_contained(Order, Hint) &&
"Target hint is outside allocation order.");
#endif
return AllocationOrder(std::move(Hints), Order, HardHints);
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 5fe7a9d35dc9a..90d2edebedd72 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1484,10 +1484,9 @@ void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
// Scan the operands of this machine instruction, replacing any uses of Old
// with New.
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (I->getOperand(i).isMBB() &&
- I->getOperand(i).getMBB() == Old)
- I->getOperand(i).setMBB(New);
+ for (MachineOperand &MO : I->operands())
+ if (MO.isMBB() && MO.getMBB() == Old)
+ MO.setMBB(New);
}
// Update the successor information.
diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
index 5522c25be3949..de4a1ac2a3baf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
@@ -622,11 +622,11 @@ void ScheduleDAGFast::ListScheduleBottomUp() {
}
// Add the nodes that aren't ready back onto the available list.
- for (unsigned i = 0, e = NotReady.size(); i != e; ++i) {
- NotReady[i]->isPending = false;
+ for (SUnit *SU : NotReady) {
+ SU->isPending = false;
// May no longer be available due to backtracking.
- if (NotReady[i]->isAvailable)
- AvailableQueue.push(NotReady[i]);
+ if (SU->isAvailable)
+ AvailableQueue.push(SU);
}
NotReady.clear();
More information about the llvm-commits
mailing list