diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index cfd247e7c3caf..302dd37ff3d67 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -1532,10 +1532,12 @@ void HoistSpillHelper::runHoistSpills( MachineBasicBlock *Block = (*RIt)->getBlock(); // If Block contains an original spill, simply continue. - if (SpillsToKeep.contains(*RIt) && !SpillsToKeep[*RIt]) { - SpillsInSubTreeMap[*RIt].first.insert(*RIt); - // SpillsInSubTreeMap[*RIt].second contains the cost of spill. - SpillsInSubTreeMap[*RIt].second = MBFI.getBlockFreq(Block); + if (auto It = SpillsToKeep.find(*RIt); + It != SpillsToKeep.end() && !It->second) { + auto &SIt = SpillsInSubTreeMap[*RIt]; + SIt.first.insert(*RIt); + // Sit.second contains the cost of spill. + SIt.second = MBFI.getBlockFreq(Block); continue; }