/// \brief Build a set of blocks to extract if the input blocks are viable. static SetVector<BasicBlock *> buildExtractionBlockSet(ArrayRef<BasicBlock *> BBs, DominatorTree *DT) { assert(!BBs.empty() && "The set of blocks to extract must be non-empty"); SetVector<BasicBlock *> Result; // Loop over the blocks, adding them to our set-vector, and aborting with an // empty set if we encounter invalid blocks. for (BasicBlock *BB : BBs) { // If this block is dead, don't process it. if (DT && !DT->isReachableFromEntry(BB)) continue; if (!Result.insert(BB)) llvm_unreachable("Repeated basic blocks in extraction input"); if (!CodeExtractor::isBlockValidForExtraction(*BB)) { Result.clear(); return Result; } } #ifndef NDEBUG for (SetVector<BasicBlock *>::iterator I = std::next(Result.begin()), E = Result.end(); I != E; ++I) for (pred_iterator PI = pred_begin(*I), PE = pred_end(*I); PI != PE; ++PI) assert(Result.count(*PI) && "No blocks in this region may have entries from outside the region" " except for the first block!"); #endif return Result; }
static SetVector<BasicBlock *> buildExtractionBlockSet(IteratorT BBBegin, IteratorT BBEnd) { SetVector<BasicBlock *> Result; assert(BBBegin != BBEnd); // Loop over the blocks, adding them to our set-vector, and aborting with an // empty set if we encounter invalid blocks. do { if (!Result.insert(*BBBegin)) llvm_unreachable("Repeated basic blocks in extraction input"); if (!isBlockValidForExtraction(**BBBegin)) { Result.clear(); return Result; } } while (++BBBegin != BBEnd); #ifndef NDEBUG for (SetVector<BasicBlock *>::iterator I = std::next(Result.begin()), E = Result.end(); I != E; ++I) for (pred_iterator PI = pred_begin(*I), PE = pred_end(*I); PI != PE; ++PI) assert(Result.count(*PI) && "No blocks in this region may have entries from outside the region" " except for the first block!"); #endif return Result; }