Skip to content

Commit c9bb1d8

Browse files
[CodeGen] Avoid repeated hash lookups (NFC)
1 parent d017767 commit c9bb1d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/CodeGen/MachineDebugify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,13 @@ bool applyDebugifyMetadataToMachineFunction(MachineModuleInfo &MMI,
123123

124124
// Find a suitable local variable for the DBG_VALUE.
125125
unsigned Line = MI.getDebugLoc().getLine();
126-
if (!Line2Var.count(Line))
126+
auto It = Line2Var.find(Line);
127+
if (It == Line2Var.end()) {
127128
Line = EarliestDVI ? EarliestDVI->getDebugLoc().getLine()
128129
: EarliestDVR->getDebugLoc().getLine();
129-
DILocalVariable *LocalVar = Line2Var[Line];
130+
It = Line2Var.try_emplace(Line).first;
131+
}
132+
DILocalVariable *LocalVar = It->second;
130133
assert(LocalVar && "No variable for current line?");
131134
VarSet.insert(LocalVar);
132135

0 commit comments

Comments
 (0)