+void RAGreedy::growRegion(InterferenceCache::Cursor Intf) {
+ // Keep track of through blocks that have already been added to SpillPlacer.
+ SparseBitVector<> Added;
+ SmallVector<unsigned, 16> ThroughBlocks;
+#ifndef NDEBUG
+ unsigned Visited = 0;
+#endif
+ for (;;) {
+ ArrayRef<unsigned> NewBundles = SpillPlacer->getRecentPositive();
+ if (NewBundles.empty())
+ break;
+ // Find new through blocks in the periphery of PrefRegBundles.
+ for (int i = 0, e = NewBundles.size(); i != e; ++i) {
+ unsigned Bundle = NewBundles[i];
+ // Look at all blocks connected to Bundle in the full graph.
+ ArrayRef<unsigned> Blocks = Bundles->getBlocks(Bundle);
+ for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
+ I != E; ++I) {
+ unsigned Block = *I;
+ if (!SA->isThroughBlock(Block) || !Added.test_and_set(Block))
+ continue;
+ // This is a new through block. Add it to SpillPlacer later.
+ ThroughBlocks.push_back(Block);
+#ifndef NDEBUG
+ ++Visited;
+#endif
+ }
+ }
+ // Any new blocks to add?
+ if (!ThroughBlocks.empty()) {
+ addThroughConstraints(Intf, ThroughBlocks);
+ ThroughBlocks.clear();
+ }
+ // Perhaps iterating can enable more bundles?
+ SpillPlacer->iterate();
+ }
+
+ // Rememeber the relevant set of through blocks for splitAroundRegion().
+ ActiveThroughBlocks |= Added;
+ DEBUG(dbgs() << ", v=" << Visited);
+}