Check if a block has a terminator first before calling front() on
authorAlkis Evlogimenos <alkis@evlogimenos.com>
Sat, 4 Dec 2004 02:30:42 +0000 (02:30 +0000)
committerAlkis Evlogimenos <alkis@evlogimenos.com>
Sat, 4 Dec 2004 02:30:42 +0000 (02:30 +0000)
it. If a block has a terminator then it is certainly non-empty so the
verifier will not crash on it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18484 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index 3a3e6e5c3253e1a367a366ff5f0478ddd89f6b20..4653ef89551f5941bc27707adf6fad93aadc4567 100644 (file)
@@ -321,6 +321,9 @@ void Verifier::visitFunction(Function &F) {
 void Verifier::visitBasicBlock(BasicBlock &BB) {
   InstsInThisBlock.clear();
 
+  // Ensure that basic blocks have terminators!
+  Assert1(BB.getTerminator(), "Basic Block does not have terminator!", &BB);
+
   // Check constraints that this basic block imposes on all of the PHI nodes in
   // it.
   if (isa<PHINode>(BB.front())) {
@@ -364,9 +367,6 @@ void Verifier::visitBasicBlock(BasicBlock &BB) {
       }
     }
   }
-
-  // Ensure that basic blocks have terminators!
-  Assert1(BB.getTerminator(), "Basic Block does not have terminator!", &BB);
 }
 
 void Verifier::visitTerminatorInst(TerminatorInst &I) {