Skip to content

Commit bda4fc0

Browse files
[NVPTX] Avoid repeated map lookups (NFC) (#111627)
1 parent 48e4d67 commit bda4fc0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,13 +1145,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
11451145
const Function *demotedFunc = nullptr;
11461146
if (!processDemoted && canDemoteGlobalVar(GVar, demotedFunc)) {
11471147
O << "// " << GVar->getName() << " has been demoted\n";
1148-
if (localDecls.find(demotedFunc) != localDecls.end())
1149-
localDecls[demotedFunc].push_back(GVar);
1150-
else {
1151-
std::vector<const GlobalVariable *> temp;
1152-
temp.push_back(GVar);
1153-
localDecls[demotedFunc] = temp;
1154-
}
1148+
localDecls[demotedFunc].push_back(GVar);
11551149
return;
11561150
}
11571151

@@ -1368,10 +1362,11 @@ void NVPTXAsmPrinter::AggBuffer::printWords(raw_ostream &os) {
13681362
}
13691363

13701364
void NVPTXAsmPrinter::emitDemotedVars(const Function *f, raw_ostream &O) {
1371-
if (localDecls.find(f) == localDecls.end())
1365+
auto It = localDecls.find(f);
1366+
if (It == localDecls.end())
13721367
return;
13731368

1374-
std::vector<const GlobalVariable *> &gvars = localDecls[f];
1369+
std::vector<const GlobalVariable *> &gvars = It->second;
13751370

13761371
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
13771372
const NVPTXSubtarget &STI =

0 commit comments

Comments
 (0)