-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[SPIRV] Use range-based for loops (NFC) #169241
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_20251123_clang_tidy_modernize-loop-convert_SPIRV
Nov 24, 2025
Merged
[SPIRV] Use range-based for loops (NFC) #169241
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20251123_clang_tidy_modernize-loop-convert_SPIRV
Nov 24, 2025
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
Identified with modernize-loop-convert.
Member
|
@llvm/pr-subscribers-backend-spir-v Author: Kazu Hirata (kazutakahirata) ChangesIdentified with modernize-loop-convert. Full diff: https://github.com/llvm/llvm-project/pull/169241.diff 1 Files Affected:
diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index bd754d17694b8..00f750b88a608 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -494,8 +494,8 @@ MCRegister SPIRVModuleAnalysis::handleVariable(
void SPIRVModuleAnalysis::collectDeclarations(const Module &M) {
InstrGRegsMap SignatureToGReg;
std::map<const Value *, unsigned> GlobalToGReg;
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ for (const Function &F : M) {
+ MachineFunction *MF = MMI->getMachineFunction(F);
if (!MF)
continue;
const MachineRegisterInfo &MRI = MF->getRegInfo();
@@ -634,10 +634,10 @@ static void collectOtherInstr(MachineInstr &MI, SPIRV::ModuleAnalysisInfo &MAI,
// be correctly collected until these registers are globally numbered.
void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
InstrTraces IS;
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- if (F->isDeclaration())
+ for (const Function &F : M) {
+ if (F.isDeclaration())
continue;
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ MachineFunction *MF = MMI->getMachineFunction(F);
assert(MF);
for (MachineBasicBlock &MBB : *MF)
@@ -669,13 +669,13 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
collectOtherInstr(MI, MAI, SPIRV::MB_AliasingInsts, IS);
} else if (TII->isDecorationInstr(MI)) {
collectOtherInstr(MI, MAI, SPIRV::MB_Annotations, IS);
- collectFuncNames(MI, &*F);
+ collectFuncNames(MI, &F);
} else if (TII->isConstantInstr(MI)) {
// Now OpSpecConstant*s are not in DT,
// but they need to be collected anyway.
collectOtherInstr(MI, MAI, SPIRV::MB_TypeConstVars, IS);
} else if (OpCode == SPIRV::OpFunction) {
- collectFuncNames(MI, &*F);
+ collectFuncNames(MI, &F);
} else if (OpCode == SPIRV::OpTypeForwardPointer) {
collectOtherInstr(MI, MAI, SPIRV::MB_TypeConstVars, IS, false);
}
@@ -687,10 +687,10 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
// the result in global register alias table. Some registers are already
// numbered.
void SPIRVModuleAnalysis::numberRegistersGlobally(const Module &M) {
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- if ((*F).isDeclaration())
+ for (const Function &F : M) {
+ if (F.isDeclaration())
continue;
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ MachineFunction *MF = MMI->getMachineFunction(F);
assert(MF);
for (MachineBasicBlock &MBB : *MF) {
for (MachineInstr &MI : MBB) {
@@ -2169,8 +2169,8 @@ void addInstrRequirements(const MachineInstr &MI,
static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
MachineModuleInfo *MMI, const SPIRVSubtarget &ST) {
// Collect requirements for existing instructions.
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ for (const Function &F : M) {
+ MachineFunction *MF = MMI->getMachineFunction(F);
if (!MF)
continue;
for (const MachineBasicBlock &MBB : *MF)
@@ -2250,8 +2250,7 @@ static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
if (RequireKHRFloatControls2)
MAI.Reqs.addExtension(SPIRV::Extension::SPV_KHR_float_controls2);
}
- for (auto FI = M.begin(), E = M.end(); FI != E; ++FI) {
- const Function &F = *FI;
+ for (const Function &F : M) {
if (F.isDeclaration())
continue;
if (F.getMetadata("reqd_work_group_size"))
@@ -2431,23 +2430,23 @@ static void addDecorations(const Module &M, const SPIRVInstrInfo &TII,
MachineModuleInfo *MMI, const SPIRVSubtarget &ST,
SPIRV::ModuleAnalysisInfo &MAI,
const SPIRVGlobalRegistry *GR) {
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ for (const Function &F : M) {
+ MachineFunction *MF = MMI->getMachineFunction(F);
if (!MF)
continue;
for (auto &MBB : *MF)
for (auto &MI : MBB)
handleMIFlagDecoration(MI, ST, TII, MAI.Reqs, GR,
- MAI.FPFastMathDefaultInfoMap[&(*F)]);
+ MAI.FPFastMathDefaultInfoMap[&F]);
}
}
static void addMBBNames(const Module &M, const SPIRVInstrInfo &TII,
MachineModuleInfo *MMI, const SPIRVSubtarget &ST,
SPIRV::ModuleAnalysisInfo &MAI) {
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ for (const Function &F : M) {
+ MachineFunction *MF = MMI->getMachineFunction(F);
if (!MF)
continue;
MachineRegisterInfo &MRI = MF->getRegInfo();
@@ -2467,8 +2466,8 @@ static void addMBBNames(const Module &M, const SPIRVInstrInfo &TII,
// patching Instruction::PHI to SPIRV::OpPhi
static void patchPhis(const Module &M, SPIRVGlobalRegistry *GR,
const SPIRVInstrInfo &TII, MachineModuleInfo *MMI) {
- for (auto F = M.begin(), E = M.end(); F != E; ++F) {
- MachineFunction *MF = MMI->getMachineFunction(*F);
+ for (const Function &F : M) {
+ MachineFunction *MF = MMI->getMachineFunction(F);
if (!MF)
continue;
for (auto &MBB : *MF) {
|
shiltian
approved these changes
Nov 24, 2025
aadeshps-mcw
pushed a commit
to aadeshps-mcw/llvm-project
that referenced
this pull request
Nov 26, 2025
Identified with modernize-loop-convert.
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Nov 26, 2025
Identified with modernize-loop-convert.
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.
Identified with modernize-loop-convert.