[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #120848)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 21 10:17:24 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/120848.diff
1 Files Affected:
- (modified) llvm/include/llvm/IR/ModuleSummaryIndex.h (+3-4)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/120848
More information about the llvm-commits
mailing list