From 786b218229369529bb360b38e883661252e47020 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 21 Dec 2024 09:36:56 -0800 Subject: [PATCH] [IR] Avoid repeated hash lookups (NFC) --- llvm/include/llvm/IR/ModuleSummaryIndex.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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