[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #110450)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 29 22:05:10 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/110450
None
>From 39416e94dd8d78ab4afed00462cce2f1cde005c7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 29 Sep 2024 09:02:26 -0700
Subject: [PATCH] [IR] Avoid repeated hash lookups (NFC)
---
llvm/lib/IR/AsmWriter.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
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
More information about the llvm-commits
mailing list