From 86a9a7a9c4bc9fb750b424a5ff233d6228d7f1bb Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 29 Jun 2004 23:34:27 +0000 Subject: [PATCH] Implement verification feature. Ensure output occurs even in the face of an error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14499 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-abcd/llvm-abcd.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/llvm-abcd/llvm-abcd.cpp b/tools/llvm-abcd/llvm-abcd.cpp index b879cf80707..820de7fe805 100644 --- a/tools/llvm-abcd/llvm-abcd.cpp +++ b/tools/llvm-abcd/llvm-abcd.cpp @@ -29,6 +29,7 @@ // the bytecode file (-dump option). //===----------------------------------------------------------------------===// +#include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/Analyzer.h" #include "Support/CommandLine.h" #include "llvm/System/Signals.h" @@ -41,7 +42,8 @@ static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); static cl::opt NoDetails ("nodetails", cl::desc("Skip detailed output")); -static cl::opt Dump ("dump", cl::desc("Detailed output")); +static cl::opt Dump ("dump", cl::desc("Dump low level bytecode trace")); +static cl::opt Verify ("verify", cl::desc("Progressively verify module")); int main(int argc, char **argv) @@ -59,9 +61,25 @@ main(int argc, char **argv) /// Determine what to generate bca.dumpBytecode = Dump; bca.detailedResults = !NoDetails; + bca.progressiveVerify = Verify; /// Analyze the bytecode file - AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage); + Module* M = AnalyzeBytecodeFile(InputFilename, bca, &ErrorMessage); + + // All that abcd does is write the gathered statistics to the output + PrintBytecodeAnalysis(bca,*Out); + + if ( M && Verify ) { + std::string verificationMsg; + try { + verifyModule( *M, ThrowExceptionAction ); + } catch (std::string& errmsg ) { + verificationMsg = errmsg; + } + if ( verificationMsg.length() > 0 ) + std::cerr << "Final Verification Message: " << verificationMsg << "\n"; + } + // If there was an error, print it and stop. if ( ErrorMessage.size() ) { @@ -69,8 +87,6 @@ main(int argc, char **argv) return 1; } - // All that abcd does is write the gathered statistics to the output - PrintBytecodeAnalysis(bca,*Out); if (Out != &std::cout) { ((std::ofstream*)Out)->close();