Skip to content

Commit 5e22a53

Browse files
[Target] Use range-based for loops (NFC) (#98705)
1 parent 3fa409f commit 5e22a53

16 files changed

+28
-49
lines changed

llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,12 +2596,10 @@ bool AMDGPUMachineCFGStructurizer::structurizeComplexRegion(RegionMRT *Region) {
25962596

25972597
unsigned BBSelectRegIn;
25982598
unsigned BBSelectRegOut;
2599-
for (auto CI = Children->begin(), CE = Children->end(); CI != CE; ++CI) {
2599+
for (MRT *Child : *Children) {
26002600
LLVM_DEBUG(dbgs() << "CurrentRegion: \n");
26012601
LLVM_DEBUG(LRegion->print(dbgs(), TRI));
26022602

2603-
MRT *Child = (*CI);
2604-
26052603
if (Child->isRegion()) {
26062604

26072605
LinearizedRegion *InnerLRegion =

llvm/lib/Target/AMDGPU/R600MachineCFGStructurizer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ int R600MachineCFGStructurizer::mergeLoop(MachineLoop *LoopRep) {
10141014
MBBVector ExitBlks;
10151015
LoopRep->getExitBlocks(ExitBlks);
10161016
SmallPtrSet<MachineBasicBlock *, 2> ExitBlkSet;
1017-
for (unsigned i = 0, e = ExitBlks.size(); i < e; ++i)
1018-
ExitBlkSet.insert(ExitBlks[i]);
1017+
for (MachineBasicBlock *MBB : ExitBlks)
1018+
ExitBlkSet.insert(MBB);
10191019
assert(ExitBlkSet.size() == 1);
10201020
MachineBasicBlock *ExitBlk = *ExitBlks.begin();
10211021
assert(ExitBlk && "Loop has several exit block");
@@ -1024,10 +1024,10 @@ int R600MachineCFGStructurizer::mergeLoop(MachineLoop *LoopRep) {
10241024
if (LoopRep->contains(LB))
10251025
LatchBlks.push_back(LB);
10261026

1027-
for (unsigned i = 0, e = ExitingMBBs.size(); i < e; ++i)
1028-
mergeLoopbreakBlock(ExitingMBBs[i], ExitBlk);
1029-
for (unsigned i = 0, e = LatchBlks.size(); i < e; ++i)
1030-
settleLoopcontBlock(LatchBlks[i], LoopHeader);
1027+
for (MachineBasicBlock *MBB : ExitingMBBs)
1028+
mergeLoopbreakBlock(MBB, ExitBlk);
1029+
for (MachineBasicBlock *MBB : LatchBlks)
1030+
settleLoopcontBlock(MBB, LoopHeader);
10311031
int Match = 0;
10321032
do {
10331033
Match = 0;

llvm/lib/Target/AMDGPU/R600Packetizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ class R600PacketizerList : public VLIWPacketizerList {
186186
if (PredI != PredJ)
187187
return false;
188188
if (SUJ->isSucc(SUI)) {
189-
for (unsigned i = 0, e = SUJ->Succs.size(); i < e; ++i) {
190-
const SDep &Dep = SUJ->Succs[i];
189+
for (const SDep &Dep : SUJ->Succs) {
191190
if (Dep.getSUnit() != SUI)
192191
continue;
193192
if (Dep.getKind() == SDep::Anti)

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,8 +2233,7 @@ bool ARMConstantIslands::optimizeThumb2JumpTables() {
22332233
if (!MJTI) return false;
22342234

22352235
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
2236-
for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) {
2237-
MachineInstr *MI = T2JumpTables[i];
2236+
for (MachineInstr *MI : T2JumpTables) {
22382237
const MCInstrDesc &MCID = MI->getDesc();
22392238
unsigned NumOps = MCID.getNumOperands();
22402239
unsigned JTOpIdx = NumOps - (MI->isPredicable() ? 2 : 1);
@@ -2429,8 +2428,7 @@ bool ARMConstantIslands::reorderThumb2JumpTables() {
24292428
if (!MJTI) return false;
24302429

24312430
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
2432-
for (unsigned i = 0, e = T2JumpTables.size(); i != e; ++i) {
2433-
MachineInstr *MI = T2JumpTables[i];
2431+
for (MachineInstr *MI : T2JumpTables) {
24342432
const MCInstrDesc &MCID = MI->getDesc();
24352433
unsigned NumOps = MCID.getNumOperands();
24362434
unsigned JTOpIdx = NumOps - (MI->isPredicable() ? 2 : 1);

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4519,11 +4519,10 @@ SDValue ARMTargetLowering::LowerFormalArguments(
45194519
// argument, as they will be allocated a stack slot below the CFA (Canonical
45204520
// Frame Address, the stack pointer at entry to the function).
45214521
unsigned ArgRegBegin = ARM::R4;
4522-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
4522+
for (const CCValAssign &VA : ArgLocs) {
45234523
if (CCInfo.getInRegsParamsProcessed() >= CCInfo.getInRegsParamsCount())
45244524
break;
45254525

4526-
CCValAssign &VA = ArgLocs[i];
45274526
unsigned Index = VA.getValNo();
45284527
ISD::ArgFlagsTy Flags = Ins[Index].Flags;
45294528
if (!Flags.isByVal())

llvm/lib/Target/ARM/MVEGatherScatterLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,7 @@ bool MVEGatherScatterLowering::runOnFunction(Function &F) {
12791279
}
12801280
}
12811281
}
1282-
for (unsigned i = 0; i < Gathers.size(); i++) {
1283-
IntrinsicInst *I = Gathers[i];
1282+
for (IntrinsicInst *I : Gathers) {
12841283
Instruction *L = lowerGather(I);
12851284
if (L == nullptr)
12861285
continue;
@@ -1290,8 +1289,7 @@ bool MVEGatherScatterLowering::runOnFunction(Function &F) {
12901289
Changed = true;
12911290
}
12921291

1293-
for (unsigned i = 0; i < Scatters.size(); i++) {
1294-
IntrinsicInst *I = Scatters[i];
1292+
for (IntrinsicInst *I : Scatters) {
12951293
Instruction *S = lowerScatter(I);
12961294
if (S == nullptr)
12971295
continue;

llvm/lib/Target/Hexagon/HexagonTfrCleanup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ bool HexagonTfrCleanup::runOnMachineFunction(MachineFunction &MF) {
289289
HII = HST.getInstrInfo();
290290
TRI = HST.getRegisterInfo();
291291

292-
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
293-
MachineBasicBlock &B = *I;
292+
for (MachineBasicBlock &B : MF) {
294293
MachineBasicBlock::iterator J, F, NextJ;
295294
IMap.clear();
296295
bool Inserted = false, Erased = false;

llvm/lib/Target/Lanai/LanaiISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,7 @@ SDValue LanaiTargetLowering::LowerCCCArguments(
451451
CCInfo.AnalyzeFormalArguments(Ins, CC_Lanai32);
452452
}
453453

454-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
455-
CCValAssign &VA = ArgLocs[i];
454+
for (const CCValAssign &VA : ArgLocs) {
456455
if (VA.isRegLoc()) {
457456
// Arguments passed in registers
458457
EVT RegVT = VA.getLocVT();

llvm/lib/Target/PowerPC/PPCFastISel.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,7 @@ bool PPCFastISel::processCallArgs(SmallVectorImpl<Value*> &Args,
13881388
CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags, CC_PPC64_ELF_FIS);
13891389

13901390
// Bail out if we can't handle any of the arguments.
1391-
for (unsigned I = 0, E = ArgLocs.size(); I != E; ++I) {
1392-
CCValAssign &VA = ArgLocs[I];
1391+
for (const CCValAssign &VA : ArgLocs) {
13931392
MVT ArgVT = ArgVTs[VA.getValNo()];
13941393

13951394
// Skip vector arguments for now, as well as long double and
@@ -1426,8 +1425,7 @@ bool PPCFastISel::processCallArgs(SmallVectorImpl<Value*> &Args,
14261425
unsigned NextFPR = PPC::F1;
14271426

14281427
// Process arguments.
1429-
for (unsigned I = 0, E = ArgLocs.size(); I != E; ++I) {
1430-
CCValAssign &VA = ArgLocs[I];
1428+
for (const CCValAssign &VA : ArgLocs) {
14311429
unsigned Arg = ArgRegs[VA.getValNo()];
14321430
MVT ArgVT = ArgVTs[VA.getValNo()];
14331431

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,8 +1954,8 @@ void PPCInstrInfo::storeRegToStackSlotNoUpd(
19541954

19551955
StoreRegToStackSlot(MF, SrcReg, isKill, FrameIdx, RC, NewMIs);
19561956

1957-
for (unsigned i = 0, e = NewMIs.size(); i != e; ++i)
1958-
MBB.insert(MI, NewMIs[i]);
1957+
for (MachineInstr *NewMI : NewMIs)
1958+
MBB.insert(MI, NewMI);
19591959

19601960
const MachineFrameInfo &MFI = MF.getFrameInfo();
19611961
MachineMemOperand *MMO = MF.getMachineMemOperand(
@@ -2001,8 +2001,8 @@ void PPCInstrInfo::loadRegFromStackSlotNoUpd(
20012001

20022002
LoadRegFromStackSlot(MF, DL, DestReg, FrameIdx, RC, NewMIs);
20032003

2004-
for (unsigned i = 0, e = NewMIs.size(); i != e; ++i)
2005-
MBB.insert(MI, NewMIs[i]);
2004+
for (MachineInstr *NewMI : NewMIs)
2005+
MBB.insert(MI, NewMI);
20062006

20072007
const MachineFrameInfo &MFI = MF.getFrameInfo();
20082008
MachineMemOperand *MMO = MF.getMachineMemOperand(

llvm/lib/Target/Sparc/SparcISelLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,7 @@ SDValue SparcTargetLowering::LowerFormalArguments_64(
638638
// The argument array begins at %fp+BIAS+128, after the register save area.
639639
const unsigned ArgArea = 128;
640640

641-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
642-
CCValAssign &VA = ArgLocs[i];
641+
for (const CCValAssign &VA : ArgLocs) {
643642
if (VA.isRegLoc()) {
644643
// This argument is passed in a register.
645644
// All integer register arguments are promoted by the caller to i64.
@@ -1179,8 +1178,7 @@ Register SparcTargetLowering::getRegisterByName(const char* RegName, LLT VT,
11791178
// AnalyzeCallOperands().
11801179
static void fixupVariableFloatArgs(SmallVectorImpl<CCValAssign> &ArgLocs,
11811180
ArrayRef<ISD::OutputArg> Outs) {
1182-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
1183-
CCValAssign &VA = ArgLocs[i];
1181+
for (CCValAssign &VA : ArgLocs) {
11841182
MVT ValTy = VA.getLocVT();
11851183
// FIXME: What about f32 arguments? C promotes them to f64 when calling
11861184
// varargs functions.

llvm/lib/Target/SystemZ/SystemZElimCompare.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,7 @@ bool SystemZElimCompare::adjustCCMasksForInstr(
420420
if (!MIEquivalentToCmp) {
421421
// Now check whether these flags are enough for all users.
422422
SmallVector<MachineOperand *, 4> AlterMasks;
423-
for (unsigned int I = 0, E = CCUsers.size(); I != E; ++I) {
424-
MachineInstr *CCUserMI = CCUsers[I];
425-
423+
for (MachineInstr *CCUserMI : CCUsers) {
426424
// Fail if this isn't a use of CC that we understand.
427425
unsigned Flags = CCUserMI->getDesc().TSFlags;
428426
unsigned FirstOpNum;

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,9 +2098,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
20982098
RetCCInfo.AnalyzeCallResult(Ins, RetCC_SystemZ);
20992099

21002100
// Copy all of the result registers out of their specified physreg.
2101-
for (unsigned I = 0, E = RetLocs.size(); I != E; ++I) {
2102-
CCValAssign &VA = RetLocs[I];
2103-
2101+
for (CCValAssign &VA : RetLocs) {
21042102
// Copy the value out, gluing the copy to the end of the call sequence.
21052103
SDValue RetValue = DAG.getCopyFromReg(Chain, DL, VA.getLocReg(),
21062104
VA.getLocVT(), Glue);

llvm/lib/Target/VE/VEISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ SDValue VETargetLowering::LowerFormalArguments(
459459
// by CC_VE would be correct now.
460460
CCInfo.AnalyzeFormalArguments(Ins, getParamCC(CallConv, false));
461461

462-
for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
463-
CCValAssign &VA = ArgLocs[i];
462+
for (const CCValAssign &VA : ArgLocs) {
464463
assert(!VA.needsCustom() && "Unexpected custom lowering");
465464
if (VA.isRegLoc()) {
466465
// This argument is passed in a register.

llvm/lib/Target/XCore/XCoreISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,7 @@ static SDValue LowerCallResult(SDValue Chain, SDValue InGlue,
973973
SmallVectorImpl<SDValue> &InVals) {
974974
SmallVector<std::pair<int, unsigned>, 4> ResultMemLocs;
975975
// Copy results out of physical registers.
976-
for (unsigned i = 0, e = RVLocs.size(); i != e; ++i) {
977-
const CCValAssign &VA = RVLocs[i];
976+
for (const CCValAssign &VA : RVLocs) {
978977
if (VA.isRegLoc()) {
979978
Chain = DAG.getCopyFromReg(Chain, dl, VA.getLocReg(), VA.getValVT(),
980979
InGlue).getValue(1);

llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ bool XCoreLowerThreadLocal::lowerGlobal(GlobalVariable *GV) {
154154

155155
// Update uses.
156156
SmallVector<User *, 16> Users(GV->users());
157-
for (unsigned I = 0, E = Users.size(); I != E; ++I) {
158-
User *U = Users[I];
157+
for (User *U : Users) {
159158
Instruction *Inst = cast<Instruction>(U);
160159
IRBuilder<> Builder(Inst);
161160
Function *GetID = Intrinsic::getDeclaration(GV->getParent(),

0 commit comments

Comments
 (0)