From 7202acacf7fa927f26981caddb77cb3919f22d89 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Sat, 4 Dec 2004 02:30:42 +0000 Subject: [PATCH] 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 --- lib/VMCore/Verifier.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 3a3e6e5c325..4653ef89551 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -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(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) {