Skip to content

Commit b284e09

Browse files
fda0igcbot
authored andcommitted
Iterate using references in IGC
Iterate through containers using auto& instead of auto.
1 parent 45f08b2 commit b284e09

23 files changed

+42
-42
lines changed

IGC/AdaptorOCL/LowerInvokeSIMD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ bool LowerInvokeSIMD::runOnModule(Module &M) {
195195

196196
// If there are uses of vc functions outside invoke_simd calls (e.g. function
197197
// pointer is taken), replace the old functions with new.
198-
for (auto it : m_OldFuncToNewFuncMap) {
198+
for (const auto &it : m_OldFuncToNewFuncMap) {
199199
Function *OldFunc = it.first;
200200
Function *NewFunc = it.second;
201201
for (auto &use : OldFunc->uses()) {

IGC/AdaptorOCL/OCL/sp/spp_g8.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ bool CGen8OpenCLProgram::GetZEBinary(
797797
if (IGC_IS_FLAG_DISABLED(ElfTempDumpEnable))
798798
{
799799
// Remove all temporary input ELF files
800-
for (auto elfFile : elfVecNames)
800+
for (const auto &elfFile : elfVecNames)
801801
{
802802
if (elfFile.compare(elfLinkerLogName.c_str()))
803803
{

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class SPIRVModuleImpl : public SPIRVModule {
346346
};
347347

348348
SPIRVModuleImpl::~SPIRVModuleImpl() {
349-
for (auto I : IdEntryMap)
349+
for (const auto &I : IdEntryMap)
350350
delete I.second;
351351

352352
for (auto I : EntryNoId)

IGC/Compiler/CISACodeGen/AtomicOptPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ bool AtomicOptPass::runOnFunction(Function &F)
205205
}
206206
}
207207

208-
for (auto T : AtomicsEmulationToProcess)
208+
for (const auto &T : AtomicsEmulationToProcess)
209209
{
210210
Instruction *AtomicInstr = std::get<0>(T);
211211
BasicBlock *BackBb = std::get<1>(T);

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3808,7 +3808,7 @@ namespace IGC
38083808
}
38093809
void CEncoder::SetBuilderOptions(VISABuilder* pbuilder)
38103810
{
3811-
for (auto OP : m_visaUserOptions)
3811+
for (const auto &OP : m_visaUserOptions)
38123812
{
38133813
switch (OP.second.type)
38143814
{
@@ -5748,7 +5748,7 @@ namespace IGC
57485748
}
57495749

57505750
// Export global symbols
5751-
for (auto global : modMD->inlineProgramScopeOffsets)
5751+
for (const auto &global : modMD->inlineProgramScopeOffsets)
57525752
{
57535753
GlobalVariable* pGlobal = global.first;
57545754

@@ -5809,7 +5809,7 @@ namespace IGC
58095809
{
58105810
std::vector<vISA::GenSymEntry> tempBufferData;
58115811
// Collect the data just for the symbol table entries
5812-
for (auto I : symbolTableList)
5812+
for (const auto &I : symbolTableList)
58135813
{
58145814
auto symbolEntry = I.second;
58155815
tempBufferData.push_back(symbolEntry);
@@ -5831,7 +5831,7 @@ namespace IGC
58315831
ModuleMetaData* modMD = m_program->GetContext()->getModuleMetaData();
58325832

58335833
// Get the data for zebin
5834-
for (auto I : symbolTableList)
5834+
for (const auto &I : symbolTableList)
58355835
{
58365836
Value* symbolValue = I.first;
58375837
auto symbolEntry = I.second;
@@ -5912,7 +5912,7 @@ namespace IGC
59125912
tableEntries = 0;
59135913

59145914
std::vector<vISA::GenFuncAttribEntry> attribTable;
5915-
for (auto it : funcAttributeMap)
5915+
for (const auto &it : funcAttributeMap)
59165916
{
59175917
vISA::GenFuncAttribEntry entry;
59185918
Function* F = it.first;
@@ -5983,7 +5983,7 @@ namespace IGC
59835983
{
59845984
ModuleMetaData* modMD = m_program->GetContext()->getModuleMetaData();
59855985

5986-
for (auto global : modMD->inlineProgramScopeOffsets)
5986+
for (const auto &global : modMD->inlineProgramScopeOffsets)
59875987
{
59885988
GlobalVariable* pGlobal = global.first;
59895989
if (pGlobal->hasAttribute("host_var_name"))

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ void CShader::AllocateSimplePushConstants(uint& offset)
645645
{
646646
for (unsigned int i = 0; i < pushInfo.simplePushBufferUsed; i++)
647647
{
648-
for (auto I : pushInfo.simplePushInfoArr[i].simplePushLoads)
648+
for (const auto &I : pushInfo.simplePushInfoArr[i].simplePushLoads)
649649
{
650650
uint subOffset = I.first;
651651
CVariable* var = GetSymbol(m_argListCache[I.second]);

IGC/Compiler/CISACodeGen/EstimateFunctionSize.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ namespace {
427427

428428
void FunctionNode::print(raw_ostream& os) {
429429
os << "Function: " << F->getName() << ", " << InitialSize << "\n";
430-
for (auto G : CalleeList)
430+
for (const auto &G : CalleeList)
431431
os << "--->>>" << G.first->F->getName() << "\n";
432-
for (auto G : CallerList)
432+
for (const auto &G : CallerList)
433433
os << "<<<---" << G.first->F->getName() << "\n";
434434
}
435435
#endif
@@ -933,7 +933,7 @@ bool EstimateFunctionSize::onlyCalledOnce(const Function* F) {
933933
auto MdWrapper = getAnalysisIfAvailable<MetaDataUtilsWrapper>();
934934
if (MdWrapper) {
935935
auto pMdUtils = MdWrapper->getMetaDataUtils();
936-
for (auto node : Node->CallerList) {
936+
for (const auto &node : Node->CallerList) {
937937
FunctionNode* Caller = node.first;
938938
uint32_t cnt = node.second;
939939
if (cnt > 1) {
@@ -1104,7 +1104,7 @@ void EstimateFunctionSize::UpdateSizeAfterCollapsing(std::deque<void*> &nodesToP
11041104
}
11051105
}
11061106

1107-
for (auto c : Node->CallerList)
1107+
for (const auto &c : Node->CallerList)
11081108
{
11091109
FunctionNode* caller = c.first;
11101110
uint16_t call_cnt = c.second;
@@ -1156,7 +1156,7 @@ uint32_t EstimateFunctionSize::updateExpandedUnitSize(Function* F, bool ignoreSt
11561156
<< ", Total chunck size: " << unitTotalSize);
11571157
}
11581158

1159-
for (auto c : node->CallerList)
1159+
for (const auto &c : node->CallerList)
11601160
{
11611161
FunctionNode* caller = c.first;
11621162
if (FunctionsInUnit.find(caller) == FunctionsInUnit.end()) //Caller is in another compilation unit
@@ -1222,7 +1222,7 @@ uint32_t EstimateFunctionSize::bottomUpHeuristic(Function* F, uint32_t& stackCal
12221222
}
12231223
}
12241224

1225-
for (auto c : Node->CallerList)
1225+
for (const auto &c : Node->CallerList)
12261226
{
12271227
FunctionNode* caller = c.first;
12281228
if (FunctionsInUnit.find(caller) == FunctionsInUnit.end()) //The caller is in another kernel, skip

IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void GenXCodeGenModule::processFunction(Function& F)
248248
// have the same SIMD sizes, otherwise we cannot make it an indirect call
249249
int simd_size = 0;
250250
unsigned CallersPerSIMD[3] = { 0, 0, 0 };
251-
for (auto iter : CallerFGs)
251+
for (const auto &iter : CallerFGs)
252252
{
253253
Function* callerKernel = iter.first->getHead();
254254
auto funcInfoMD = pMdUtils->getFunctionsInfoItem(callerKernel);
@@ -314,7 +314,7 @@ void GenXCodeGenModule::processFunction(Function& F)
314314
}
315315

316316
bool FirstPair = true;
317-
for (auto FGPair : CallerFGs)
317+
for (const auto &FGPair : CallerFGs)
318318
{
319319
if (FirstPair)
320320
{
@@ -986,7 +986,7 @@ void GenXFunctionGroupAnalysis::CloneFunctionGroupForMultiSIMDCompile(llvm::Modu
986986
auto pNewICG = getOrCreateIndirectCallGroup(pModule, simdsz);
987987
addToFunctionGroup(FCloned, pNewICG, FCloned);
988988

989-
for (auto iter : UsersMap)
989+
for (const auto &iter : UsersMap)
990990
{
991991
if (iter.second == simdsz)
992992
{

IGC/Compiler/ModuleAllocaAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool ModuleAllocaAnalysis::safeToUseScratchSpace() const
164164
if (Ctx.type == ShaderType::OPENCL_SHADER && IGC_IS_FLAG_ENABLED(ForceStatelessForQueueT)) {
165165
if (!F.arg_empty()) {
166166
KernelArgs kernelArgs(F, DL, pMdUtils, &modMD, Ctx.platform.getGRFSize());
167-
for (auto arg : kernelArgs) {
167+
for (const auto &arg : kernelArgs) {
168168
const KernelArg::ArgType argTy = arg.getArgType();
169169
if (argTy == KernelArg::ArgType::PTR_DEVICE_QUEUE)
170170
{

IGC/Compiler/Optimizer/BuiltInFuncImport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ bool PreBIImportAnalysis::runOnModule(Module& M)
14451445
}
14461446
}
14471447

1448-
for (auto InstTuple : InstToModify)
1448+
for (const auto &InstTuple : InstToModify)
14491449
{
14501450
auto inst = std::get<0>(InstTuple);
14511451
auto value = std::get<1>(InstTuple);

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryToSLM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ namespace IGC
191191

192192
// Calculate an offset for new SLM variables.
193193
unsigned int offset = 0;
194-
for (auto offsets : ModuleMD->FuncMD[F].localOffsets)
194+
for (const auto &offsets : ModuleMD->FuncMD[F].localOffsets)
195195
{
196196
PointerType* ptrType = dyn_cast<PointerType>(offsets.m_Var->getType());
197197
Type* varType = IGCLLVM::getNonOpaquePtrEltTy(ptrType);

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool ProgramScopeConstantAnalysis::runOnModule(Module& M)
251251
{
252252
// Add globals tracked in metadata to the "llvm.used" list so they won't be deleted by optimizations
253253
llvm::SmallVector<GlobalValue*, 4> gvec;
254-
for (auto Node : inlineProgramScopeOffsets)
254+
for (const auto &Node : inlineProgramScopeOffsets)
255255
{
256256
gvec.push_back(Node.first);
257257
}
@@ -346,7 +346,7 @@ bool ProgramScopeConstantAnalysis::runOnModule(Module& M)
346346
}
347347

348348
const bool changed = !inlineProgramScopeOffsets.empty();
349-
for (auto offset : inlineProgramScopeOffsets)
349+
for (const auto &offset : inlineProgramScopeOffsets)
350350
{
351351
std::string globalName = offset.first->getName().str();
352352
if (Ctx->m_retryManager.IsFirstTry())

IGC/Compiler/Optimizer/OpenCLPasses/ResourceAllocator/ResourceAllocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool ResourceAllocator::runOnFunction(llvm::Function& F)
264264
allocationMode = BindlessAllocationMode::Preferred;
265265
}
266266

267-
for (auto arg : kernelArgs)
267+
for (const auto &arg : kernelArgs)
268268
{
269269
const AllocationType allocType = getAllocationType(arg.getArgType(), allocationMode);
270270

@@ -356,7 +356,7 @@ bool ResourceAllocator::runOnFunction(llvm::Function& F)
356356
}
357357

358358
// Param allocations must be inserted to the Metadata Utils in order.
359-
for (auto i : paramAllocations)
359+
for (const auto &i : paramAllocations)
360360
{
361361
resAllocMD->argAllocMDList.push_back(i);
362362
}

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ void StatelessToStateful::finalizeArgInitialValue(Function* F)
924924
Type* int32Ty = Type::getInt32Ty(M->getContext());
925925
Value* ZeroValue = ConstantInt::get(int32Ty, 0);
926926

927-
for (auto II : m_argsInfo)
927+
for (const auto &II : m_argsInfo)
928928
{
929929
const KernelArg* kernelArg = II.first;
930930
int mapVal = II.second;

IGC/Compiler/Optimizer/OpenCLPasses/SubGroupFuncs/SubGroupFuncsResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void SubGroupFuncsResolution::CheckSIMDSize(Instruction& I, StringRef msg)
265265

266266
WaveOps SubGroupFuncsResolution::GetWaveOp(StringRef funcName)
267267
{
268-
for (auto op : SubGroupFuncsResolution::m_spvOpToWaveOpMap)
268+
for (const auto &op : SubGroupFuncsResolution::m_spvOpToWaveOpMap)
269269
{
270270
if (funcName.contains(op.first))
271271
{

IGC/Compiler/Optimizer/PreCompiledFuncImport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ bool PreCompiledFuncImport::runOnModule(Module& M)
810810
}
811811
}
812812

813-
for (auto p : replaceInsts)
813+
for (const auto &p : replaceInsts)
814814
{
815815
p.first->replaceAllUsesWith(p.second);
816816
p.first->eraseFromParent();
@@ -998,7 +998,7 @@ bool PreCompiledFuncImport::runOnModule(Module& M)
998998
}
999999

10001000
// free FuncsImpArgs
1001-
for (auto I : FuncsImpArgs) {
1001+
for (const auto &I : FuncsImpArgs) {
10021002
ImplicitArgs* IA = I.second;
10031003
delete IA;
10041004
}

IGC/Compiler/Optimizer/ReduceOptPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool ReduceOptPass::createReduceWI0(Instruction *ReduceInstr) {
6565
std::string Prefix = "__builtin_IB_WorkGroupReduce_WI0_";
6666

6767
std::string Op = "";
68-
for (auto I : OpSet) {
68+
for (const auto &I : OpSet) {
6969
if (Name.find(I) != std::string::npos) {
7070
Op = I;
7171
break;

IGC/Compiler/Optimizer/Scalarizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ void ScalarizeFunction::resolveDeferredInstructions()
14001400
}
14011401
}
14021402

1403-
for ( auto entry : dummyToScalarMap )
1403+
for (const auto &entry : dummyToScalarMap)
14041404
{
14051405
// Replace and erase all dummy instructions (don't use eraseFromParent as the dummy is not in the function)
14061406
Instruction *dummyInst = cast<Instruction>(entry.first);

IGC/Compiler/SPIRMetaDataTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void SPIRMetaDataTranslation::translateKernelMetadataIntoOpenCLKernelsMD(Module&
9595
Func.getContext().getMDKindNames(Names);
9696
Func.getAllMetadata(Info);
9797
Args.push_back(ConstantAsMetadata::get(&Func));
98-
for (auto i : Info)
98+
for (const auto &i : Info)
9999
{
100100
llvm::SmallVector<Metadata*, 2> Mdvector;
101101
auto firstElem = MDString::get(M.getContext(), Names[i.first]);

IGC/Compiler/SampleMultiversioning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ bool SampleMultiversioning::runOnFunction(Function& F)
284284
}
285285
else
286286
{
287-
for (auto tempSI : SampleInsts)
287+
for (const auto &tempSI : SampleInsts)
288288
{
289289
// Corner case where two samplers can be branched for one Mul.
290290
if (val_insn == tempSI.Sample)

IGC/DebugInfo/DwarfDebug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ void DwarfDebug::collectVariableInfo(
15621562
write(TempDotDebugLocEntries.back().loc, (unsigned char *)&startRange,
15631563
pointerSize);
15641564

1565-
for (auto it : allCallerSave) {
1565+
for (const auto &it : allCallerSave) {
15661566
TempDotDebugLocEntries.back().end = std::get<0>(it);
15671567
write(TempDotDebugLocEntries.back().loc,
15681568
(unsigned char *)&std::get<0>(it), pointerSize);
@@ -1768,7 +1768,7 @@ void DwarfDebug::collectVariableInfo(
17681768
continue;
17691769
}
17701770

1771-
for (auto range : GenISARange) {
1771+
for (const auto &range : GenISARange) {
17721772
DbgValuesWithGenIP[RegVar].push_back(
17731773
std::make_tuple(range.first, range.second, RegVar, pInst));
17741774
}

IGC/DebugInfo/VISAModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ VISAModule::getAllCallerSave(const VISAObjectDebugInfo &VDI,
295295
if (startRange < callerSaveIp) {
296296
callerRestoreIp = std::min<uint64_t>(endRange, callerRestoreIp);
297297
// Variable is live over stack call function.
298-
for (auto callerSaveReg : (*callerSaveStartIt).data) {
298+
for (const auto &callerSaveReg : (*callerSaveStartIt).data) {
299299
// startRegNum is saved to caller save area around the stack call.
300300
if ((callerSaveReg.srcRegOff / getGRFSizeInBytes()) == startRegNum) {
301301
// Emit caller save/restore only if %ip is within range

IGC/ElfPackager/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
272272
if (FuncName.str().find("__builtin_IB_") == std::string::npos &&
273273
FuncName.str().find("llvm.") == std::string::npos)
274274
{
275-
for (auto iterator2 : FunctionList)
275+
for (const auto &iterator2 : FunctionList)
276276
{
277277
if (FuncName.find(iterator2) != std::string::npos)
278278
{
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
337337
else
338338
counter = 2;
339339

340-
for (auto map_iterator : Map)
340+
for (const auto &map_iterator : Map)
341341
{
342342
std::vector<GlobalValue*> ExtractValue = map_iterator.second;
343343
llvm::ValueToValueMapTy Val;
@@ -351,7 +351,7 @@ int main(int argc, char *argv[])
351351
ElfMap[map_iterator.first] = OS.str().str();
352352
}
353353

354-
for (auto map_iterator : Map)
354+
for (const auto &map_iterator : Map)
355355
{
356356
std::vector<GlobalValue*> ExtractValue = map_iterator.second;
357357
for (size_t i = 0, e = ExtractValue.size(); i != e; ++i)
@@ -459,7 +459,7 @@ int main(int argc, char *argv[])
459459
}
460460

461461
//Now to add all of the sections in the file
462-
for (auto elf_iterator : ElfMap)
462+
for (const auto &elf_iterator : ElfMap)
463463
{
464464
CreateElfSection(pWriter,
465465
sectionNode,

0 commit comments

Comments
 (0)