Skip to content

Commit 3874620

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (llvm#125025)
1 parent fc43308 commit 3874620

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,10 +914,10 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
914914
if (!VI.Var || !VI.inStackSlot())
915915
continue;
916916
int Slot = VI.getStackSlot();
917-
if (SlotRemap.count(Slot)) {
917+
if (auto It = SlotRemap.find(Slot); It != SlotRemap.end()) {
918918
LLVM_DEBUG(dbgs() << "Remapping debug info for ["
919919
<< cast<DILocalVariable>(VI.Var)->getName() << "].\n");
920-
VI.updateStackSlot(SlotRemap[Slot]);
920+
VI.updateStackSlot(It->second);
921921
FixedDbg++;
922922
}
923923
}
@@ -1004,10 +1004,11 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
10041004
if (!AI)
10051005
continue;
10061006

1007-
if (!Allocas.count(AI))
1007+
auto It = Allocas.find(AI);
1008+
if (It == Allocas.end())
10081009
continue;
10091010

1010-
MMO->setValue(Allocas[AI]);
1011+
MMO->setValue(It->second);
10111012
FixedMemOp++;
10121013
}
10131014

@@ -1173,8 +1174,8 @@ void StackColoring::expungeSlotMap(DenseMap<int, int> &SlotRemap,
11731174
// Expunge slot remap map.
11741175
for (unsigned i=0; i < NumSlots; ++i) {
11751176
// If we are remapping i
1176-
if (SlotRemap.count(i)) {
1177-
int Target = SlotRemap[i];
1177+
if (auto It = SlotRemap.find(i); It != SlotRemap.end()) {
1178+
int Target = It->second;
11781179
// As long as our target is mapped to something else, follow it.
11791180
while (SlotRemap.count(Target)) {
11801181
Target = SlotRemap[Target];

0 commit comments

Comments
 (0)