[llvm-commits] [llvm] r156164 - /llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp

Chandler Carruth chandlerc at gmail.com
Fri May 4 03:26:46 PDT 2012


Author: chandlerc
Date: Fri May  4 05:26:45 2012
New Revision: 156164

URL: http://llvm.org/viewvc/llvm-project?rev=156164&view=rev
Log:
Hoist a safety assert from the extraction method into the construction
of the extractor itself.

Modified:
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp

Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=156164&r1=156163&r2=156164&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Fri May  4 05:26:45 2012
@@ -67,6 +67,8 @@
 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 @@
     }
   }
 
+#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 @@
   // 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);
 





More information about the llvm-commits mailing list