Check if a block has a terminator first before calling front() on

it. If a block has a terminator then it is certainly non-empty so the
verifier will not crash on it.

llvm-svn: 18484
This commit is contained in:
Alkis Evlogimenos 2004-12-04 02:30:42 +00:00
parent b92de19116
commit be526cfba4
1 changed files with 3 additions and 3 deletions

View 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) {