-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Use range-based for loops (NFC) #98459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeGen] Use range-based for loops (NFC) #98459
Conversation
@llvm/pr-subscribers-llvm-selectiondag Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/98459.diff 3 Files Affected:
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();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/50/builds/1013 Here is the relevant piece of the build log for the reference:
|
No description provided.