Skip to content

Commit 4eb6e95

Browse files
mateuszchudykigcbot
authored andcommitted
Don't make a copy in a foreach loop.
Don't make a copy in a foreach loop.
1 parent a9bc8ce commit 4eb6e95

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

IGC/AdaptorCommon/AddImplicitArgs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ bool AddImplicitArgs::runOnModule(Module &M)
134134

135135
if (!IGC::ForceAlwaysInline(ctx))
136136
{
137-
for (auto I : funcsMappingForReplacement)
137+
for (const auto& I : funcsMappingForReplacement)
138138
{
139139
replaceAllUsesWithNewOCLBuiltinFunction(I.first, I.second);
140140
}
141141
}
142142

143143
// Update IGC Metadata
144144
// Function declarations are changing, this needs to be reflected in the metadata.
145-
for (auto i : funcsMapping)
145+
for (const auto& i : funcsMapping)
146146
{
147147
IGCMD::IGCMetaDataHelper::moveFunction(
148148
*m_pMdUtils, *ctx->getModuleMetaData(), i.first, i.second);
@@ -275,7 +275,7 @@ void AddImplicitArgs::updateNewFuncArgs(llvm::Function* pFunc, llvm::Function* p
275275
// byval. Bug#GD-429 had this exact issue. If we don't do this then we lose
276276
// mapping of argument to dbg.declare and elf file comes up with empty
277277
// storage location for the variable.
278-
for (auto toReplace : newAddr)
278+
for (const auto& toReplace : newAddr)
279279
{
280280
auto d = dyn_cast<DbgDeclareInst>(toReplace.first);
281281

@@ -600,7 +600,7 @@ void BuiltinCallGraphAnalysis::traverseCallGraphSCC(const std::vector<CallGraphN
600600
// calculate args from sub-routine.
601601
// This function have not been processed yet, therefore no map-entry for it yet
602602
IGC_ASSERT(argMap.count(f) == 0);
603-
for (auto N : (*CGN))
603+
for (const auto& N : (*CGN))
604604
{
605605
Function *sub = N.second->getFunction();
606606
// if callee has not been visited

IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void LegalizeFunctionSignatures::FixFunctionSignatures(Module& M)
350350

351351
void LegalizeFunctionSignatures::FixFunctionBody(Module& M)
352352
{
353-
for (auto iter : oldToNewFuncMap)
353+
for (const auto& iter : oldToNewFuncMap)
354354
{
355355
Function* pFunc = iter.first;
356356
Function* pNewFunc = iter.second;
@@ -483,7 +483,7 @@ void LegalizeFunctionSignatures::FixFunctionUsers(Module& M)
483483
std::vector<CallInst*> callsToFix;
484484

485485
// Check for all users of the old function and replace with the new signature
486-
for (auto it : oldToNewFuncMap)
486+
for (const auto& it : oldToNewFuncMap)
487487
{
488488
Function* pFunc = it.first;
489489
Function* pNewFunc = it.second;

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static bool convertRecursionToStackCall(CallGraph& CG)
190190
{
191191
// Check self-recursion.
192192
auto Node = SCCNodes.back();
193-
for (auto Callee : *Node)
193+
for (const auto& Callee : *Node)
194194
{
195195
if (Callee.second == Node)
196196
{

0 commit comments

Comments
 (0)