-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[CodeGen] Use range-based for loops (NFC) #98104
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
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_clang_tidy_modernize_loop_convert_CodeGen
Jul 10, 2024
Merged
[CodeGen] Use range-based for loops (NFC) #98104
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_clang_tidy_modernize_loop_convert_CodeGen
Jul 10, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-llvm-regalloc Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/98104.diff 4 Files Affected:
diff --git a/llvm/lib/CodeGen/InterferenceCache.cpp b/llvm/lib/CodeGen/InterferenceCache.cpp
index ae197ee5553ae..fb76f44c25019 100644
--- a/llvm/lib/CodeGen/InterferenceCache.cpp
+++ b/llvm/lib/CodeGen/InterferenceCache.cpp
@@ -136,14 +136,12 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
// Use advanceTo only when possible.
if (PrevPos != Start) {
if (!PrevPos.isValid() || Start < PrevPos) {
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- RegUnitInfo &RUI = RegUnits[i];
+ for (RegUnitInfo &RUI : RegUnits) {
RUI.VirtI.find(Start);
RUI.FixedI = RUI.Fixed->find(Start);
}
} else {
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- RegUnitInfo &RUI = RegUnits[i];
+ for (RegUnitInfo &RUI : RegUnits) {
RUI.VirtI.advanceTo(Start);
if (RUI.FixedI != RUI.Fixed->end())
RUI.FixedI = RUI.Fixed->advanceTo(RUI.FixedI, Start);
@@ -162,8 +160,8 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
BI->First = BI->Last = SlotIndex();
// Check for first interference from virtregs.
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- LiveIntervalUnion::SegmentIter &I = RegUnits[i].VirtI;
+ for (RegUnitInfo &RUI : RegUnits) {
+ LiveIntervalUnion::SegmentIter &I = RUI.VirtI;
if (!I.valid())
continue;
SlotIndex StartI = I.start();
@@ -174,9 +172,9 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
}
// Same thing for fixed interference.
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- LiveInterval::const_iterator I = RegUnits[i].FixedI;
- LiveInterval::const_iterator E = RegUnits[i].Fixed->end();
+ for (RegUnitInfo &RUI : RegUnits) {
+ LiveInterval::const_iterator I = RUI.FixedI;
+ LiveInterval::const_iterator E = RUI.Fixed->end();
if (I == E)
continue;
SlotIndex StartI = I->start;
@@ -213,8 +211,8 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
}
// Check for last interference in block.
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- LiveIntervalUnion::SegmentIter &I = RegUnits[i].VirtI;
+ for (RegUnitInfo &RUI : RegUnits) {
+ LiveIntervalUnion::SegmentIter &I = RUI.VirtI;
if (!I.valid() || I.start() >= Stop)
continue;
I.advanceTo(Stop);
@@ -229,9 +227,9 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
}
// Fixed interference.
- for (unsigned i = 0, e = RegUnits.size(); i != e; ++i) {
- LiveInterval::iterator &I = RegUnits[i].FixedI;
- LiveRange *LR = RegUnits[i].Fixed;
+ for (RegUnitInfo &RUI : RegUnits) {
+ LiveInterval::iterator &I = RUI.FixedI;
+ LiveRange *LR = RUI.Fixed;
if (I == LR->end() || I->start >= Stop)
continue;
I = LR->advanceTo(I, Stop);
diff --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index f9162b444e03d..fae4b90ed7f18 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -1536,8 +1536,7 @@ void LiveIntervals::handleMoveIntoNewBundle(MachineInstr &BundleStart,
// Fix up dead defs
const SlotIndex Index = getInstructionIndex(BundleStart);
- for (unsigned Idx = 0, E = BundleStart.getNumOperands(); Idx != E; ++Idx) {
- MachineOperand &MO = BundleStart.getOperand(Idx);
+ for (MachineOperand &MO : BundleStart.operands()) {
if (!MO.isReg())
continue;
Register Reg = MO.getReg();
diff --git a/llvm/lib/CodeGen/MachineConvergenceVerifier.cpp b/llvm/lib/CodeGen/MachineConvergenceVerifier.cpp
index 8ec85bdf48d45..3d3c55faa8246 100644
--- a/llvm/lib/CodeGen/MachineConvergenceVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineConvergenceVerifier.cpp
@@ -51,8 +51,7 @@ GenericConvergenceVerifier<MachineSSAContext>::findAndCheckConvergenceTokenUsed(
const MachineRegisterInfo &MRI = Context.getFunction()->getRegInfo();
const MachineInstr *TokenDef = nullptr;
- for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) {
- const MachineOperand &MO = MI.getOperand(I);
+ for (const MachineOperand &MO : MI.operands()) {
if (!MO.isReg() || !MO.isUse())
continue;
Register OpReg = MO.getReg();
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index f0de2cad20337..2b083e1dc3210 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1041,8 +1041,7 @@ unsigned MachineInstr::getBundleSize() const {
/// Returns true if the MachineInstr has an implicit-use operand of exactly
/// the given register (not considering sub/super-registers).
bool MachineInstr::hasRegisterImplicitUseOperand(Register Reg) const {
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
- const MachineOperand &MO = getOperand(i);
+ for (const MachineOperand &MO : operands()) {
if (MO.isReg() && MO.isUse() && MO.isImplicit() && MO.getReg() == Reg)
return true;
}
|
dwblaikie
approved these changes
Jul 9, 2024
f281c23
to
9d2f550
Compare
aaryanshukla
pushed a commit
to aaryanshukla/llvm-project
that referenced
this pull request
Jul 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.