[llvm] [CodeGen][NFC] Remove redundant map lookup (PR #125342)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 1 01:04:14 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-regalloc
Author: Balazs Benics (steakhal)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/125342.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/InlineSpiller.cpp (+6-3)
``````````diff
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);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/125342
More information about the llvm-commits
mailing list