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 findOneNVVMAnnotation(const GlobalValue *gv,