[llvm] 530fe60 - [IR] Avoid repeated hash lookups (NFC) (#120848)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 21 17:41:03 PST 2024
Author: Kazu Hirata
Date: 2024-12-21T17:41:01-08:00
New Revision: 530fe60bf8e94702541c581e7bc54a6031cd6f1e
URL: https://github.com/llvm/llvm-project/commit/530fe60bf8e94702541c581e7bc54a6031cd6f1e
DIFF: https://github.com/llvm/llvm-project/commit/530fe60bf8e94702541c581e7bc54a6031cd6f1e.diff
LOG: [IR] Avoid repeated hash lookups (NFC) (#120848)
Added:
Modified:
llvm/include/llvm/IR/ModuleSummaryIndex.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 2a05c2ac0758c0..3c586a1dd21d82 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
More information about the llvm-commits
mailing list