[llvm] [NVPTX] Avoid repeated map lookups (NFC) (PR #111627)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 21:08:45 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111627
None
>From 68e7a7d939f4d2802db024084d883a1867503bac Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 8 Oct 2024 20:47:32 -0700
Subject: [PATCH] [NVPTX] Avoid repeated map lookups (NFC)
---
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 12f6161cbf61bc..7f4e1035e7a70a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1145,13 +1145,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
const Function *demotedFunc = nullptr;
if (!processDemoted && canDemoteGlobalVar(GVar, demotedFunc)) {
O << "// " << GVar->getName() << " has been demoted\n";
- if (localDecls.find(demotedFunc) != localDecls.end())
- localDecls[demotedFunc].push_back(GVar);
- else {
- std::vector<const GlobalVariable *> temp;
- temp.push_back(GVar);
- localDecls[demotedFunc] = temp;
- }
+ localDecls[demotedFunc].push_back(GVar);
return;
}
@@ -1368,10 +1362,11 @@ void NVPTXAsmPrinter::AggBuffer::printWords(raw_ostream &os) {
}
void NVPTXAsmPrinter::emitDemotedVars(const Function *f, raw_ostream &O) {
- if (localDecls.find(f) == localDecls.end())
+ auto It = localDecls.find(f);
+ if (It == localDecls.end())
return;
- std::vector<const GlobalVariable *> &gvars = localDecls[f];
+ std::vector<const GlobalVariable *> &gvars = It->second;
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
const NVPTXSubtarget &STI =
More information about the llvm-commits
mailing list