[llvm] [CodeGen][NFC] Remove redundant map lookup (PR #125342)
Balazs Benics via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 1 01:01:38 PST 2025
https://github.com/steakhal created https://github.com/llvm/llvm-project/pull/125342
None
>From 1ba043b9228c5452e5dc57aa0f6a57318533e2ba Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Sat, 1 Feb 2025 09:58:48 +0100
Subject: [PATCH] [CodeGen][NFC] Remove redundant map lookup
---
llvm/lib/CodeGen/InlineSpiller.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index 33915d0f7f8297..cfd247e7c3caf6 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -1320,13 +1320,16 @@ void HoistSpillHelper::addToMergeableSpills(MachineInstr &Spill, int StackSlot,
LiveInterval &OrigLI = LIS.getInterval(Original);
// save a copy of LiveInterval in StackSlotToOrigLI because the original
// LiveInterval may be cleared after all its references are spilled.
- if (!StackSlotToOrigLI.contains(StackSlot)) {
+
+ auto [Place, Inserted] = StackSlotToOrigLI.try_emplace(StackSlot);
+ if (Inserted) {
auto LI = std::make_unique<LiveInterval>(OrigLI.reg(), OrigLI.weight());
LI->assign(OrigLI, Allocator);
- StackSlotToOrigLI[StackSlot] = std::move(LI);
+ Place->second = std::move(LI);
}
+
SlotIndex Idx = LIS.getInstructionIndex(Spill);
- VNInfo *OrigVNI = StackSlotToOrigLI[StackSlot]->getVNInfoAt(Idx.getRegSlot());
+ VNInfo *OrigVNI = Place->second->getVNInfoAt(Idx.getRegSlot());
std::pair<int, VNInfo *> MIdx = std::make_pair(StackSlot, OrigVNI);
MergeableSpills[MIdx].insert(&Spill);
}
More information about the llvm-commits
mailing list