Skip to content

Commit 16d4453

Browse files
authored
[CodeGen][NFC] Remove redundant map lookup (llvm#125342)
1 parent 48f8865 commit 16d4453

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/CodeGen/InlineSpiller.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,13 +1320,16 @@ void HoistSpillHelper::addToMergeableSpills(MachineInstr &Spill, int StackSlot,
13201320
LiveInterval &OrigLI = LIS.getInterval(Original);
13211321
// save a copy of LiveInterval in StackSlotToOrigLI because the original
13221322
// LiveInterval may be cleared after all its references are spilled.
1323-
if (!StackSlotToOrigLI.contains(StackSlot)) {
1323+
1324+
auto [Place, Inserted] = StackSlotToOrigLI.try_emplace(StackSlot);
1325+
if (Inserted) {
13241326
auto LI = std::make_unique<LiveInterval>(OrigLI.reg(), OrigLI.weight());
13251327
LI->assign(OrigLI, Allocator);
1326-
StackSlotToOrigLI[StackSlot] = std::move(LI);
1328+
Place->second = std::move(LI);
13271329
}
1330+
13281331
SlotIndex Idx = LIS.getInstructionIndex(Spill);
1329-
VNInfo *OrigVNI = StackSlotToOrigLI[StackSlot]->getVNInfoAt(Idx.getRegSlot());
1332+
VNInfo *OrigVNI = Place->second->getVNInfoAt(Idx.getRegSlot());
13301333
std::pair<int, VNInfo *> MIdx = std::make_pair(StackSlot, OrigVNI);
13311334
MergeableSpills[MIdx].insert(&Spill);
13321335
}

0 commit comments

Comments
 (0)