Skip to content

Commit 9220f64

Browse files
[NVPTX] Avoid repeated hash lookups (NFC) (llvm#112117)
1 parent b2cac3b commit 9220f64

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

llvm/lib/Target/NVPTX/NVPTXUtilities.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ static void cacheAnnotationFromMD(const MDNode *MetadataNode,
8787
// assert: there can only exist one unique key value pair of
8888
// the form (string key, MDNode node). Operands of such a node
8989
// shall always be unsigned ints.
90-
if (retval.find(Key) == retval.end()) {
91-
readIntVecFromMDNode(VecMd, retval[Key]);
90+
auto [It, Inserted] = retval.try_emplace(Key);
91+
if (Inserted) {
92+
readIntVecFromMDNode(VecMd, It->second);
9293
continue;
9394
}
9495
} else {
@@ -122,13 +123,7 @@ static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) {
122123
if (tmp.empty()) // no annotations for this gv
123124
return;
124125

125-
if (AC.Cache.find(m) != AC.Cache.end())
126-
AC.Cache[m][gv] = std::move(tmp);
127-
else {
128-
global_val_annot_t tmp1;
129-
tmp1[gv] = std::move(tmp);
130-
AC.Cache[m] = std::move(tmp1);
131-
}
126+
AC.Cache[m][gv] = std::move(tmp);
132127
}
133128

134129
static std::optional<unsigned> findOneNVVMAnnotation(const GlobalValue *gv,

0 commit comments

Comments
 (0)