[llvm] [IR] Avoid repeated map lookups (NFC) (PR #128396)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 22 20:16:29 PST 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/128396

None

>From eaa8e13c0441f953eb54bf06b9fe754c540c72a4 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 22 Feb 2025 15:05:13 -0800
Subject: [PATCH] [IR] Avoid repeated map lookups (NFC)

---
 llvm/include/llvm/IR/ModuleSummaryIndexYAML.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
index b23fd4a72c93b..14b8ce5df8536 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -229,8 +229,7 @@ template <> struct CustomMappingTraits<GlobalValueSummaryMapTy> {
           static_cast<GlobalValueSummary::ImportKind>(GVSum.ImportType));
       if (GVSum.Aliasee) {
         auto ASum = std::make_unique<AliasSummary>(GVFlags);
-        if (!V.count(*GVSum.Aliasee))
-          V.emplace(*GVSum.Aliasee, /*IsAnalysis=*/false);
+        V.try_emplace(*GVSum.Aliasee, /*IsAnalysis=*/false);
         ValueInfo AliaseeVI(/*IsAnalysis=*/false, &*V.find(*GVSum.Aliasee));
         // Note: Aliasee cannot be filled until all summaries are loaded.
         // This is done in fixAliaseeLinks() which is called in



More information about the llvm-commits mailing list