Skip to content

Commit 7dd531f

Browse files
[SPIRV] Use range-based for loops (NFC) (#169241)
Identified with modernize-loop-convert.
1 parent 2b81e9e commit 7dd531f

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ MCRegister SPIRVModuleAnalysis::handleVariable(
494494
void SPIRVModuleAnalysis::collectDeclarations(const Module &M) {
495495
InstrGRegsMap SignatureToGReg;
496496
std::map<const Value *, unsigned> GlobalToGReg;
497-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
498-
MachineFunction *MF = MMI->getMachineFunction(*F);
497+
for (const Function &F : M) {
498+
MachineFunction *MF = MMI->getMachineFunction(F);
499499
if (!MF)
500500
continue;
501501
const MachineRegisterInfo &MRI = MF->getRegInfo();
@@ -634,10 +634,10 @@ static void collectOtherInstr(MachineInstr &MI, SPIRV::ModuleAnalysisInfo &MAI,
634634
// be correctly collected until these registers are globally numbered.
635635
void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
636636
InstrTraces IS;
637-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
638-
if (F->isDeclaration())
637+
for (const Function &F : M) {
638+
if (F.isDeclaration())
639639
continue;
640-
MachineFunction *MF = MMI->getMachineFunction(*F);
640+
MachineFunction *MF = MMI->getMachineFunction(F);
641641
assert(MF);
642642

643643
for (MachineBasicBlock &MBB : *MF)
@@ -669,13 +669,13 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
669669
collectOtherInstr(MI, MAI, SPIRV::MB_AliasingInsts, IS);
670670
} else if (TII->isDecorationInstr(MI)) {
671671
collectOtherInstr(MI, MAI, SPIRV::MB_Annotations, IS);
672-
collectFuncNames(MI, &*F);
672+
collectFuncNames(MI, &F);
673673
} else if (TII->isConstantInstr(MI)) {
674674
// Now OpSpecConstant*s are not in DT,
675675
// but they need to be collected anyway.
676676
collectOtherInstr(MI, MAI, SPIRV::MB_TypeConstVars, IS);
677677
} else if (OpCode == SPIRV::OpFunction) {
678-
collectFuncNames(MI, &*F);
678+
collectFuncNames(MI, &F);
679679
} else if (OpCode == SPIRV::OpTypeForwardPointer) {
680680
collectOtherInstr(MI, MAI, SPIRV::MB_TypeConstVars, IS, false);
681681
}
@@ -687,10 +687,10 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
687687
// the result in global register alias table. Some registers are already
688688
// numbered.
689689
void SPIRVModuleAnalysis::numberRegistersGlobally(const Module &M) {
690-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
691-
if ((*F).isDeclaration())
690+
for (const Function &F : M) {
691+
if (F.isDeclaration())
692692
continue;
693-
MachineFunction *MF = MMI->getMachineFunction(*F);
693+
MachineFunction *MF = MMI->getMachineFunction(F);
694694
assert(MF);
695695
for (MachineBasicBlock &MBB : *MF) {
696696
for (MachineInstr &MI : MBB) {
@@ -2169,8 +2169,8 @@ void addInstrRequirements(const MachineInstr &MI,
21692169
static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
21702170
MachineModuleInfo *MMI, const SPIRVSubtarget &ST) {
21712171
// Collect requirements for existing instructions.
2172-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
2173-
MachineFunction *MF = MMI->getMachineFunction(*F);
2172+
for (const Function &F : M) {
2173+
MachineFunction *MF = MMI->getMachineFunction(F);
21742174
if (!MF)
21752175
continue;
21762176
for (const MachineBasicBlock &MBB : *MF)
@@ -2250,8 +2250,7 @@ static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
22502250
if (RequireKHRFloatControls2)
22512251
MAI.Reqs.addExtension(SPIRV::Extension::SPV_KHR_float_controls2);
22522252
}
2253-
for (auto FI = M.begin(), E = M.end(); FI != E; ++FI) {
2254-
const Function &F = *FI;
2253+
for (const Function &F : M) {
22552254
if (F.isDeclaration())
22562255
continue;
22572256
if (F.getMetadata("reqd_work_group_size"))
@@ -2431,23 +2430,23 @@ static void addDecorations(const Module &M, const SPIRVInstrInfo &TII,
24312430
MachineModuleInfo *MMI, const SPIRVSubtarget &ST,
24322431
SPIRV::ModuleAnalysisInfo &MAI,
24332432
const SPIRVGlobalRegistry *GR) {
2434-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
2435-
MachineFunction *MF = MMI->getMachineFunction(*F);
2433+
for (const Function &F : M) {
2434+
MachineFunction *MF = MMI->getMachineFunction(F);
24362435
if (!MF)
24372436
continue;
24382437

24392438
for (auto &MBB : *MF)
24402439
for (auto &MI : MBB)
24412440
handleMIFlagDecoration(MI, ST, TII, MAI.Reqs, GR,
2442-
MAI.FPFastMathDefaultInfoMap[&(*F)]);
2441+
MAI.FPFastMathDefaultInfoMap[&F]);
24432442
}
24442443
}
24452444

24462445
static void addMBBNames(const Module &M, const SPIRVInstrInfo &TII,
24472446
MachineModuleInfo *MMI, const SPIRVSubtarget &ST,
24482447
SPIRV::ModuleAnalysisInfo &MAI) {
2449-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
2450-
MachineFunction *MF = MMI->getMachineFunction(*F);
2448+
for (const Function &F : M) {
2449+
MachineFunction *MF = MMI->getMachineFunction(F);
24512450
if (!MF)
24522451
continue;
24532452
MachineRegisterInfo &MRI = MF->getRegInfo();
@@ -2467,8 +2466,8 @@ static void addMBBNames(const Module &M, const SPIRVInstrInfo &TII,
24672466
// patching Instruction::PHI to SPIRV::OpPhi
24682467
static void patchPhis(const Module &M, SPIRVGlobalRegistry *GR,
24692468
const SPIRVInstrInfo &TII, MachineModuleInfo *MMI) {
2470-
for (auto F = M.begin(), E = M.end(); F != E; ++F) {
2471-
MachineFunction *MF = MMI->getMachineFunction(*F);
2469+
for (const Function &F : M) {
2470+
MachineFunction *MF = MMI->getMachineFunction(F);
24722471
if (!MF)
24732472
continue;
24742473
for (auto &MBB : *MF) {

0 commit comments

Comments
 (0)