diff options
author | Duncan Sands <baldrick@free.fr> | 2007-11-01 10:50:26 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-11-01 10:50:26 +0000 |
commit | 4cd1ef9bbc827e5aeeb9afc5f5583bf07b471f01 (patch) | |
tree | 9fd5dfe72118388b4f2044b9d80756fe60179ebc | |
parent | 0624133aa0e6fc1ca4535a872c5ceb0630161161 (diff) | |
download | external_llvm-4cd1ef9bbc827e5aeeb9afc5f5583bf07b471f01.zip external_llvm-4cd1ef9bbc827e5aeeb9afc5f5583bf07b471f01.tar.gz external_llvm-4cd1ef9bbc827e5aeeb9afc5f5583bf07b471f01.tar.bz2 |
Don't barf on empty basic blocks. Do not rely on assert
doing something - this needs to work for release builds
too. I chose to just abort rather than following the
fancy logic of abortIfBroken, because (1) it is a pain
to do otherwise, and (2) nothing is going to work if the
module is this broken.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43611 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 29d19c3..dea9408 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -69,22 +69,34 @@ using namespace llvm; namespace { // Anonymous namespace for class struct VISIBILITY_HIDDEN PreVerifier : public FunctionPass { static char ID; // Pass ID, replacement for typeid - + PreVerifier() : FunctionPass((intptr_t)&ID) { } - + + // Check that the prerequisites for successful DominatorTree construction + // are satisfied. bool runOnFunction(Function &F) { - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) - assert(I->back().isTerminator() - && "Block does not end with a terminator?"); - - return false; + bool Broken = false; + + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { + if (I->empty() || !I->back().isTerminator()) { + cerr << "Basic Block does not have terminator!\n"; + WriteAsOperand(*cerr, I, true); + cerr << "\n"; + Broken = true; + } + } + + if (Broken) + abort(); + + return false; } }; - + char PreVerifier::ID = 0; RegisterPass<PreVerifier> PreVer("preverify", "Preliminary module verification"); const PassInfo *PreVerifyID = PreVer.getPassInfo(); - + struct VISIBILITY_HIDDEN Verifier : public FunctionPass, InstVisitor<Verifier> { static char ID; // Pass ID, replacement for typeid |