diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-05-04 10:26:45 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-05-04 10:26:45 +0000 |
commit | 27742c1a76634312bc28cf37e89c83209576149f (patch) | |
tree | ee528a93d2b3bdbbd6a3004417035966e45f4876 /lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 99650c9088c5dd4b6788a99b63c82d13e0518961 (diff) |
Hoist a safety assert from the extraction method into the construction
of the extractor itself.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 50eb8a27e0..3d08a5dffc 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -67,6 +67,8 @@ static SetVector<BasicBlock *> buildExtractionBlockSet(ArrayRef<BasicBlock *> BBs) { SetVector<BasicBlock *> Result; + assert(!BBs.empty()); + // Loop over the blocks, adding them to our set-vector, and aborting with an // empty set if we encounter invalid blocks. for (ArrayRef<BasicBlock *>::iterator I = BBs.begin(), E = BBs.end(); @@ -80,6 +82,17 @@ buildExtractionBlockSet(ArrayRef<BasicBlock *> BBs) { } } +#ifndef NDEBUG + for (ArrayRef<BasicBlock *>::iterator I = llvm::next(BBs.begin()), + E = BBs.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; } @@ -665,15 +678,6 @@ Function *CodeExtractor::extractCodeRegion() { // block in the region. BasicBlock *header = *Blocks.begin(); - for (SetVector<BasicBlock *>::iterator BI = llvm::next(Blocks.begin()), - BE = Blocks.end(); - BI != BE; ++BI) - for (pred_iterator PI = pred_begin(*BI), E = pred_end(*BI); - PI != E; ++PI) - assert(Blocks.count(*PI) && - "No blocks in this region may have entries from outside the region" - " except for the first block!"); - // If we have to split PHI nodes or the entry block, do so now. severSplitPHINodes(header); |