Skip to content

Commit 1bfe3e7

Browse files
kazutakahiratayuxuanchen1997
authored andcommitted
Revert "[Target] Use range-based for loops (NFC) (#98844)"
Summary: This reverts commit 3614f65. fixupImmediateBr seems to resize ImmBranches. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251487
1 parent 780adaa commit 1bfe3e7

12 files changed

+31
-29
lines changed

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
478478

479479
LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n');
480480
bool BRChange = false;
481-
for (ImmBranch &Br : ImmBranches)
482-
BRChange |= fixupImmediateBr(Br);
481+
for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
482+
BRChange |= fixupImmediateBr(ImmBranches[i]);
483483
if (BRChange && ++NoBRIters > 30)
484484
report_fatal_error("Branch Fix Up pass failed to converge!");
485485
LLVM_DEBUG(dumpBBs());

llvm/lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
16731673
.addReg(ARM::SP)
16741674
.add(predOps(ARMCC::AL))
16751675
.setMIFlags(MachineInstr::FrameDestroy);
1676-
for (unsigned Reg : Regs)
1677-
MIB.addReg(Reg, getDefRegState(true));
1676+
for (unsigned i = 0, e = Regs.size(); i < e; ++i)
1677+
MIB.addReg(Regs[i], getDefRegState(true));
16781678
if (DeleteRet) {
16791679
if (MI != MBB.end()) {
16801680
MIB.copyImplicitOps(*MI);

llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,8 +2579,8 @@ ARMPreAllocLoadStoreOpt::RescheduleLoadStoreInstrs(MachineBasicBlock *MBB) {
25792579
Bases.push_back(Base);
25802580
return;
25812581
}
2582-
for (const MachineInstr *MI : BI->second) {
2583-
if (Offset == getMemoryOpOffset(*MI)) {
2582+
for (unsigned i = 0, e = BI->second.size(); i != e; ++i) {
2583+
if (Offset == getMemoryOpOffset(*BI->second[i])) {
25842584
StopHere = true;
25852585
break;
25862586
}

llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,8 @@ bool DeadCodeElimination::runOnNode(MachineDomTreeNode *N) {
10561056
continue;
10571057

10581058
B->erase(MI);
1059-
for (unsigned Reg : Regs)
1060-
MRI.markUsesInDebugValueAsUndef(Reg);
1059+
for (unsigned i = 0, n = Regs.size(); i != n; ++i)
1060+
MRI.markUsesInDebugValueAsUndef(Regs[i]);
10611061
Changed = true;
10621062
}
10631063

llvm/lib/Target/Hexagon/HexagonGenInsert.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ void HexagonGenInsert::pruneEmptyLists() {
10401040
if (I->second.empty())
10411041
Prune.push_back(I);
10421042
}
1043-
for (const auto &It : Prune)
1044-
IFMap.erase(It);
1043+
for (unsigned i = 0, n = Prune.size(); i < n; ++i)
1044+
IFMap.erase(Prune[i]);
10451045
}
10461046

10471047
void HexagonGenInsert::pruneCoveredSets(unsigned VR) {
@@ -1470,8 +1470,8 @@ bool HexagonGenInsert::removeDeadCode(MachineDomTreeNode *N) {
14701470
continue;
14711471

14721472
B->erase(MI);
1473-
for (unsigned Reg : Regs)
1474-
MRI->markUsesInDebugValueAsUndef(Reg);
1473+
for (unsigned I = 0, N = Regs.size(); I != N; ++I)
1474+
MRI->markUsesInDebugValueAsUndef(Regs[I]);
14751475
Changed = true;
14761476
}
14771477

@@ -1582,8 +1582,8 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
15821582
if (Idx >= Cutoff)
15831583
Out.push_back(I);
15841584
}
1585-
for (const auto &It : Out)
1586-
IFMap.erase(It);
1585+
for (unsigned i = 0, n = Out.size(); i < n; ++i)
1586+
IFMap.erase(Out[i]);
15871587
}
15881588
if (IFMap.empty())
15891589
return Changed;

llvm/lib/Target/Mips/MipsConstantIslandPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ bool MipsConstantIslands::runOnMachineFunction(MachineFunction &mf) {
500500

501501
LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n');
502502
bool BRChange = false;
503-
for (ImmBranch &Br : ImmBranches)
504-
BRChange |= fixupImmediateBr(Br);
503+
for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
504+
BRChange |= fixupImmediateBr(ImmBranches[i]);
505505
if (BRChange && ++NoBRIters > 30)
506506
report_fatal_error("Branch Fix Up pass failed to converge!");
507507
LLVM_DEBUG(dumpBBs());

llvm/lib/Target/Mips/MipsFastISel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,8 +1763,8 @@ bool MipsFastISel::selectRet(const Instruction *I) {
17631763
RetRegs.push_back(VA.getLocReg());
17641764
}
17651765
MachineInstrBuilder MIB = emitInst(Mips::RetRA);
1766-
for (unsigned Reg : RetRegs)
1767-
MIB.addReg(Reg, RegState::Implicit);
1766+
for (unsigned i = 0, e = RetRegs.size(); i != e; ++i)
1767+
MIB.addReg(RetRegs[i], RegState::Implicit);
17681768
return true;
17691769
}
17701770

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ void NVPTXAsmPrinter::emitGlobals(const Module &M) {
861861
*static_cast<const NVPTXSubtarget *>(NTM.getSubtargetImpl());
862862

863863
// Print out module-level global variables in proper order
864-
for (const GlobalVariable *GV : Globals)
865-
printModuleLevelGV(GV, OS2, /*processDemoted=*/false, STI);
864+
for (unsigned i = 0, e = Globals.size(); i != e; ++i)
865+
printModuleLevelGV(Globals[i], OS2, /*processDemoted=*/false, STI);
866866

867867
OS2 << '\n';
868868

llvm/lib/Target/PowerPC/PPCEarlyReturn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ namespace {
149149
Changed = true;
150150
}
151151

152-
for (MachineBasicBlock *MBB : PredToRemove)
153-
MBB->removeSuccessor(&ReturnMBB, true);
152+
for (unsigned i = 0, ie = PredToRemove.size(); i != ie; ++i)
153+
PredToRemove[i]->removeSuccessor(&ReturnMBB, true);
154154

155155
if (Changed && !ReturnMBB.hasAddressTaken()) {
156156
// We now might be able to merge this blr-only block into its

llvm/lib/Target/PowerPC/PPCFastISel.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,8 +1668,8 @@ bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
16681668
}
16691669

16701670
// Add implicit physical register uses to the call.
1671-
for (unsigned Reg : RegArgs)
1672-
MIB.addReg(Reg, RegState::Implicit);
1671+
for (unsigned II = 0, IE = RegArgs.size(); II != IE; ++II)
1672+
MIB.addReg(RegArgs[II], RegState::Implicit);
16731673

16741674
// Direct calls, in both the ELF V1 and V2 ABIs, need the TOC register live
16751675
// into the call.
@@ -1793,8 +1793,8 @@ bool PPCFastISel::SelectRet(const Instruction *I) {
17931793
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
17941794
TII.get(PPC::BLR8));
17951795

1796-
for (unsigned Reg : RetRegs)
1797-
MIB.addReg(Reg, RegState::Implicit);
1796+
for (unsigned i = 0, e = RetRegs.size(); i != e; ++i)
1797+
MIB.addReg(RetRegs[i], RegState::Implicit);
17981798

17991799
return true;
18001800
}

llvm/lib/Target/WebAssembly/WebAssemblyRegColoring.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ static void undefInvalidDbgValues(
135135
#ifndef NDEBUG
136136
DenseSet<Register> SeenRegs;
137137
#endif
138-
for (const auto &CoalescedIntervals : Assignments) {
138+
for (size_t I = 0, E = Assignments.size(); I < E; ++I) {
139+
const auto &CoalescedIntervals = Assignments[I];
139140
if (CoalescedIntervals.empty())
140141
continue;
141142
for (LiveInterval *LI : CoalescedIntervals) {

llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ bool XCoreLowerThreadLocal::runOnModule(Module &M) {
178178
for (GlobalVariable &GV : M.globals())
179179
if (GV.isThreadLocal())
180180
ThreadLocalGlobals.push_back(&GV);
181-
for (GlobalVariable *GV : ThreadLocalGlobals)
182-
MadeChange |= lowerGlobal(GV);
181+
for (unsigned I = 0, E = ThreadLocalGlobals.size(); I != E; ++I) {
182+
MadeChange |= lowerGlobal(ThreadLocalGlobals[I]);
183+
}
183184
return MadeChange;
184185
}

0 commit comments

Comments
 (0)