[llvm] 22486e0 - [LiveDebugValues] Avoid repeated hash lookups (NFC) (#109509)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 09:11:23 PDT 2024


Author: Kazu Hirata
Date: 2024-09-21T09:11:19-07:00
New Revision: 22486e031d13cad3df99be5ab6d860920b71fc80

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

LOG: [LiveDebugValues] Avoid repeated hash lookups (NFC) (#109509)

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 2d95ff9e05abe7..7e7d90f24fccba 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -1952,11 +1952,9 @@ void VarLocBasedLDV::accumulateFragmentMap(MachineInstr &MI,
   // If this is the first sighting of this variable, then we are guaranteed
   // there are currently no overlapping fragments either. Initialize the set
   // of seen fragments, record no overlaps for the current one, and return.
-  auto SeenIt = SeenFragments.find(MIVar.getVariable());
-  if (SeenIt == SeenFragments.end()) {
-    SmallSet<FragmentInfo, 4> OneFragment;
-    OneFragment.insert(ThisFragment);
-    SeenFragments.insert({MIVar.getVariable(), OneFragment});
+  auto [SeenIt, Inserted] = SeenFragments.try_emplace(MIVar.getVariable());
+  if (Inserted) {
+    SeenIt->second.insert(ThisFragment);
 
     OverlappingFragments.insert({{MIVar.getVariable(), ThisFragment}, {}});
     return;


        


More information about the llvm-commits mailing list