[llvm] [LiveDebugValues] Avoid repeated hash lookups (NFC) (PR #109509)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 20:41:29 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/109509.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp (+3-5) 


``````````diff
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;

``````````

</details>


https://github.com/llvm/llvm-project/pull/109509


More information about the llvm-commits mailing list