[llvm] 8c2714e - [ExecutionEngine] Avoid repeated hash lookups (NFC) (#130707)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 11 07:34:08 PDT 2025


Author: Kazu Hirata
Date: 2025-03-11T07:34:04-07:00
New Revision: 8c2714e44802cb36eb556a3f2940bbc2e512f6be

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

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

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
index 5a058bd712a3e..9b842180fa7a7 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp
@@ -33,10 +33,9 @@ static DenseSet<StringRef> DWARFSectionNames = {
 static void preserveDWARFSection(LinkGraph &G, Section &Sec) {
   DenseMap<Block *, Symbol *> Preserved;
   for (auto Sym : Sec.symbols()) {
-    if (Sym->isLive())
-      Preserved[&Sym->getBlock()] = Sym;
-    else if (!Preserved.count(&Sym->getBlock()))
-      Preserved[&Sym->getBlock()] = Sym;
+    auto [It, Inserted] = Preserved.try_emplace(&Sym->getBlock());
+    if (Inserted || Sym->isLive())
+      It->second = Sym;
   }
   for (auto Block : Sec.blocks()) {
     auto &PSym = Preserved[Block];


        


More information about the llvm-commits mailing list