[llvm] [LiveDebugValues] Avoid repeated hash lookups (NFC) (PR #108484)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 07:46:58 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/108484
>From 8fd8fd5969477596d7d36f253fe08d78ef56c3e7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 12 Sep 2024 01:04:53 -0700
Subject: [PATCH] [LiveDebugValues] Avoid repeated hash lookups (NFC)
---
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index a69dbbbbdab3cd..a73a3aa59403b3 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -2231,11 +2231,9 @@ void InstrRefBasedLDV::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);
OverlapFragments.insert({{MIVar.getVariable(), ThisFragment}, {}});
return;
More information about the llvm-commits
mailing list