From 4f4cf99a8662b4ee989c3ead691ba586221ea44b 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18484 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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) { -- 2.34.1