[llvm] 9220f64 - [NVPTX] Avoid repeated hash lookups (NFC) (#112117)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 13 07:33:00 PDT 2024
Author: Kazu Hirata
Date: 2024-10-13T07:32:57-07:00
New Revision: 9220f645208715a9d65e12f14ad77ecb086399d6
URL: https://github.com/llvm/llvm-project/commit/9220f645208715a9d65e12f14ad77ecb086399d6
DIFF: https://github.com/llvm/llvm-project/commit/9220f645208715a9d65e12f14ad77ecb086399d6.diff
LOG: [NVPTX] Avoid repeated hash lookups (NFC) (#112117)
Added:
Modified:
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
index 2d62f34726e88c..44c50827764b08 100644
--- a/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
@@ -87,8 +87,9 @@ static void cacheAnnotationFromMD(const MDNode *MetadataNode,
// assert: there can only exist one unique key value pair of
// the form (string key, MDNode node). Operands of such a node
// shall always be unsigned ints.
- if (retval.find(Key) == retval.end()) {
- readIntVecFromMDNode(VecMd, retval[Key]);
+ auto [It, Inserted] = retval.try_emplace(Key);
+ if (Inserted) {
+ readIntVecFromMDNode(VecMd, It->second);
continue;
}
} else {
@@ -122,13 +123,7 @@ static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) {
if (tmp.empty()) // no annotations for this gv
return;
- if (AC.Cache.find(m) != AC.Cache.end())
- AC.Cache[m][gv] = std::move(tmp);
- else {
- global_val_annot_t tmp1;
- tmp1[gv] = std::move(tmp);
- AC.Cache[m] = std::move(tmp1);
- }
+ AC.Cache[m][gv] = std::move(tmp);
}
static std::optional<unsigned> findOneNVVMAnnotation(const GlobalValue *gv,
More information about the llvm-commits
mailing list