@@ -1545,24 +1545,21 @@ void HoistSpillHelper::runHoistSpills(
15451545 for (MachineDomTreeNode *Child : (*RIt)->children ()) {
15461546 if (!SpillsInSubTreeMap.contains (Child))
15471547 continue ;
1548- // The stmt "SpillsInSubTree = SpillsInSubTreeMap[*RIt].first " below
1548+ // The stmt "auto &[...] = SpillsInSubTreeMap[*RIt]" below
15491549 // should be placed before getting the begin and end iterators of
15501550 // SpillsInSubTreeMap[Child].first, or else the iterators may be
15511551 // invalidated when SpillsInSubTreeMap[*RIt] is seen the first time
15521552 // and the map grows and then the original buckets in the map are moved.
1553- SmallPtrSet<MachineDomTreeNode *, 16 > &SpillsInSubTree =
1554- SpillsInSubTreeMap[*RIt].first ;
1555- BlockFrequency &SubTreeCost = SpillsInSubTreeMap[*RIt].second ;
1556- SubTreeCost += SpillsInSubTreeMap[Child].second ;
1557- auto BI = SpillsInSubTreeMap[Child].first .begin ();
1558- auto EI = SpillsInSubTreeMap[Child].first .end ();
1553+ auto &[SpillsInSubTree, SubTreeCost] = SpillsInSubTreeMap[*RIt];
1554+ auto ChildIt = SpillsInSubTreeMap.find (Child);
1555+ SubTreeCost += ChildIt->second .second ;
1556+ auto BI = ChildIt->second .first .begin ();
1557+ auto EI = ChildIt->second .first .end ();
15591558 SpillsInSubTree.insert (BI, EI);
1560- SpillsInSubTreeMap.erase (Child );
1559+ SpillsInSubTreeMap.erase (ChildIt );
15611560 }
15621561
1563- SmallPtrSet<MachineDomTreeNode *, 16 > &SpillsInSubTree =
1564- SpillsInSubTreeMap[*RIt].first ;
1565- BlockFrequency &SubTreeCost = SpillsInSubTreeMap[*RIt].second ;
1562+ auto &[SpillsInSubTree, SubTreeCost] = SpillsInSubTreeMap[*RIt];
15661563 // No spills in subtree, simply continue.
15671564 if (SpillsInSubTree.empty ())
15681565 continue ;
0 commit comments