[llvm] [ExecutionEngine] Avoid repeated hash lookups (NFC) (PR #130544)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 9 20:51:07 PDT 2025


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

None

>From 683dae3649a7a395f776b4f9fcb6a5eb3e067224 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 9 Mar 2025 00:53:34 -0800
Subject: [PATCH] [ExecutionEngine] Avoid repeated hash lookups (NFC)

---
 llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index 1b649227b38a0..3e359f82eeb56 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -506,10 +506,9 @@ Error DLLImportDefinitionGenerator::tryToGenerate(
     if (Deinterned.starts_with(getImpPrefix()))
       Deinterned = Deinterned.drop_front(StringRef(getImpPrefix()).size());
     // Don't degrade the required state
-    if (ToLookUpSymbols.count(Deinterned) &&
-        ToLookUpSymbols[Deinterned] == SymbolLookupFlags::RequiredSymbol)
-      continue;
-    ToLookUpSymbols[Deinterned] = KV.second;
+    auto [It, Inserted] = ToLookUpSymbols.try_emplace(Deinterned);
+    if (Inserted || It->second != SymbolLookupFlags::RequiredSymbol)
+      It->second = KV.second;
   }
 
   for (auto &KV : ToLookUpSymbols)



More information about the llvm-commits mailing list