diff options
Diffstat (limited to 'lib/IR/Verifier.cpp')
-rw-r--r-- | lib/IR/Verifier.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 420bc1507e..6a7f45f628 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -53,6 +53,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Assembly/Writer.h" +#include "llvm/DebugInfo.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" @@ -66,6 +67,7 @@ #include "llvm/PassManager.h" #include "llvm/Support/CFG.h" #include "llvm/Support/CallSite.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -74,6 +76,9 @@ #include <cstdarg> using namespace llvm; +static cl::opt<bool> DisableDebugInfoVerifier("disable-debug-info-verifier", + cl::init(false)); + namespace { // Anonymous namespace for class struct PreVerifier : public FunctionPass { static char ID; // Pass ID, replacement for typeid @@ -202,6 +207,9 @@ namespace { visitModuleFlags(M); + // Verify Debug Info. + verifyDebugInfo(M); + // If the module is broken, abort at this time. return abortIfBroken(); } @@ -309,6 +317,8 @@ namespace { void VerifyFunctionAttrs(FunctionType *FT, AttributeSet Attrs, const Value *V); + void verifyDebugInfo(Module &M); + void WriteValue(const Value *V) { if (!V) return; if (isa<Instruction>(V)) { @@ -2185,6 +2195,28 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { } } +void Verifier::verifyDebugInfo(Module &M) { + // Verify Debug Info. + if (!DisableDebugInfoVerifier) { + DebugInfoFinder Finder; + Finder.processModule(M); + + for (DebugInfoFinder::iterator I = Finder.compile_unit_begin(), + E = Finder.compile_unit_end(); I != E; ++I) + Assert1(DICompileUnit(*I).Verify(), "DICompileUnit does not Verify!", *I); + for (DebugInfoFinder::iterator I = Finder.subprogram_begin(), + E = Finder.subprogram_end(); I != E; ++I) + Assert1(DISubprogram(*I).Verify(), "DISubprogram does not Verify!", *I); + for (DebugInfoFinder::iterator I = Finder.global_variable_begin(), + E = Finder.global_variable_end(); I != E; ++I) + Assert1(DIGlobalVariable(*I).Verify(), + "DIGlobalVariable does not Verify!", *I); + for (DebugInfoFinder::iterator I = Finder.type_begin(), + E = Finder.type_end(); I != E; ++I) + Assert1(DIType(*I).Verify(), "DIType does not Verify!", *I); + } +} + //===----------------------------------------------------------------------===// // Implement the public interfaces to this file... //===----------------------------------------------------------------------===// |