/* * Perform a DFS starting at block `bid', storing the post-order in * `outVec'. */ void RegionDesc::postOrderSort(RegionDesc::BlockId bid, RegionDesc::BlockIdSet& visited, RegionDesc::BlockIdVec& outVec) { if (visited.count(bid)) return; visited.insert(bid); if (auto nextRetr = nextRetrans(bid)) { postOrderSort(nextRetr.value(), visited, outVec); } for (auto succ : succs(bid)) { postOrderSort(succ, visited, outVec); } outVec.push_back(bid); }
RegionDesc::BlockVec::iterator RegionDesc::deleteBlock(RegionDesc::BlockVec::iterator it) { const auto bid = (*it)->id(); for (auto pid : preds(bid)) removeArc(pid, bid); for (auto sid : succs(bid)) removeArc(bid, sid); if (auto nextR = nextRetrans(bid)) { auto prevR = prevRetrans(bid); clearPrevRetrans(nextR.value()); if (prevR) { clearNextRetrans(prevR.value()); setNextRetrans(prevR.value(), nextR.value()); } else { clearPrevRetrans(nextR.value()); } } else if (auto prevR = prevRetrans(bid)) { clearNextRetrans(prevR.value()); } m_data.erase(bid); return m_blocks.erase(it); }