check that terminators only occur at the end of a block. This catches the
authorChris Lattner <sabre@nondot.org>
Sat, 9 Feb 2008 01:06:01 +0000 (01:06 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 9 Feb 2008 01:06:01 +0000 (01:06 +0000)
common problem of putting two terminators in the same block.  I can't write
a testcase for this because the .ll parser rejects this before the verifier
can, but this can occur when generating IR.

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

lib/VMCore/Verifier.cpp

index 626119b43728f0991e2940d166d25d4de19136f9..3c7ce7a5a29cc736e366dcadf1b881f8801008b7 100644 (file)
@@ -1051,6 +1051,11 @@ void Verifier::visitInstruction(Instruction &I) {
               !DT->dominates(&BB->getParent()->getEntryBlock(), BB),
               "Only PHI nodes may reference their own value!", &I);
   }
+  
+  // Verify that if this is a terminator that it is at the end of the block.
+  if (isa<TerminatorInst>(I))
+    Assert1(BB->getTerminator() == &I, "Terminator not at end of block!", &I);
+  
 
   // Check that void typed values don't have names
   Assert1(I.getType() != Type::VoidTy || !I.hasName(),