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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 10:17:13 PDT 2025


Author: Kazu Hirata
Date: 2025-03-10T10:17:08-07:00
New Revision: b4caea84661400cc4c93b1e67151b70b0c88f875

URL: https://github.com/llvm/llvm-project/commit/b4caea84661400cc4c93b1e67151b70b0c88f875
DIFF: https://github.com/llvm/llvm-project/commit/b4caea84661400cc4c93b1e67151b70b0c88f875.diff

LOG: [ExecutionEngine] Avoid repeated hash lookups (NFC) (#130544)

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp

Removed: 
    


################################################################################
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