diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h index 2a05c2ac0758c..3c586a1dd21d8 100644 --- a/llvm/include/llvm/IR/ModuleSummaryIndex.h +++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h @@ -1711,10 +1711,9 @@ class ModuleSummaryIndex { GlobalValue::GUID OrigGUID) { if (OrigGUID == 0 || ValueGUID == OrigGUID) return; - if (OidGuidMap.count(OrigGUID) && OidGuidMap[OrigGUID] != ValueGUID) - OidGuidMap[OrigGUID] = 0; - else - OidGuidMap[OrigGUID] = ValueGUID; + auto [It, Inserted] = OidGuidMap.try_emplace(OrigGUID, ValueGUID); + if (!Inserted && It->second != ValueGUID) + It->second = 0; } /// Find the summary for ValueInfo \p VI in module \p ModuleId, or nullptr if