diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-19 16:12:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-19 16:12:19 +0000 |
commit | 3e1f144a1d5b989ea96b4e5fa3538daf0cc5c5a9 (patch) | |
tree | 3e9c714e692e5c8f176b0695fb213cdbf3d3df81 | |
parent | 0f82df410caf8242406fa7e8bbd555e4854ffe48 (diff) |
Make sure that we abort if an error happens as early as neccesary. Before
it was possible for the passmanager to continue running passes after the
verifier even if the module was not well formed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3820 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 456d19291b..51e0d2dddd 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -48,7 +48,6 @@ #include "llvm/Support/InstVisitor.h" #include "Support/STLExtras.h" #include <algorithm> -#include <iostream> namespace { // Anonymous namespace for class @@ -67,6 +66,13 @@ namespace { // Anonymous namespace for class bool doInitialization(Module &M) { verifySymbolTable(M.getSymbolTable()); + + // If this is a real pass, in a pass manager, we must abort before + // returning back to the pass manager, or else the pass manager may try to + // run other passes on the broken module. + // + if (RealPass) + abortIfBroken(); return false; } @@ -74,6 +80,14 @@ namespace { // Anonymous namespace for class // Get dominator information if we are being run by PassManager if (RealPass) DS = &getAnalysis<DominatorSet>(); visit(F); + + // If this is a real pass, in a pass manager, we must abort before + // returning back to the pass manager, or else the pass manager may try to + // run other passes on the broken module. + // + if (RealPass) + abortIfBroken(); + return false; } @@ -83,10 +97,8 @@ namespace { // Anonymous namespace for class if (I->isExternal() && I->hasInternalLinkage()) CheckFailed("Function Declaration has Internal Linkage!", I); - if (Broken && AbortBroken) { - std::cerr << "Broken module found, compilation aborted!\n"; - abort(); - } + // If the module is broken, abort at this time. + abortIfBroken(); return false; } @@ -96,6 +108,16 @@ namespace { // Anonymous namespace for class AU.addRequired<DominatorSet>(); } + // abortIfBroken - If the module is broken and we are supposed to abort on + // this condition, do so. + // + void abortIfBroken() const { + if (Broken && AbortBroken) { + std::cerr << "Broken module found, compilation aborted!\n"; + abort(); + } + } + // Verification methods... void verifySymbolTable(SymbolTable *ST); void visitFunction(Function &F); |