[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #110450)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 29 22:05:44 PDT 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/110450.diff
1 Files Affected:
- (modified) llvm/lib/IR/AsmWriter.cpp (+2-6)
``````````diff
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 70e3af941bf77b..280e347739cdb6 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1338,12 +1338,8 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) {
void SlotTracker::CreateAttributeSetSlot(AttributeSet AS) {
assert(AS.hasAttributes() && "Doesn't need a slot!");
- as_iterator I = asMap.find(AS);
- if (I != asMap.end())
- return;
-
- unsigned DestSlot = asNext++;
- asMap[AS] = DestSlot;
+ if (asMap.try_emplace(AS, asNext).second)
+ ++asNext;
}
/// Create a new slot for the specified Module
``````````
</details>
https://github.com/llvm/llvm-project/pull/110450
More information about the llvm-commits
mailing list