diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-03-27 22:04:28 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-03-27 22:04:28 +0000 |
commit | 49e6a70fe3e0ec79cf44c47a5503fe2fb5121dd3 (patch) | |
tree | 8c21bb8aca108f408dc52fa087bb19d556c028a3 /llvm/tools/opt/opt.cpp | |
parent | 2d6d7efb006c431d16a6c522e79617d24064c142 (diff) | |
download | bcm5719-llvm-49e6a70fe3e0ec79cf44c47a5503fe2fb5121dd3.tar.gz bcm5719-llvm-49e6a70fe3e0ec79cf44c47a5503fe2fb5121dd3.zip |
Verifier: Call verifyModule() from llc and opt
Change `llc` and `opt` to run `verifyModule()`. This ensures that we
check the full module before `FunctionPass::doInitialization()` ever
gets called (I was getting crashes in `DwarfDebug` instead of verifier
failures when testing a WIP patch that checks operands of compile
units). In `opt`, also move up debug-info-stripping so that it still
runs before verification.
There was a fair bit of broken code that was sitting in tree.
Interestingly, some were cases of a `select` that referred to itself in
`-instcombine` tests (apparently an intermediate result). I split them
off to `*-noverify.ll` tests with RUN lines like this:
opt < %s -S -disable-verify -instcombine | opt -S | FileCheck %s
This avoids verifying the input file (so we can get the broken code into
`-instcombine), but still verifies the output with a second call to
`opt` (to verify that `-instcombine` will clean it up like it should).
llvm-svn: 233432
Diffstat (limited to 'llvm/tools/opt/opt.cpp')
-rw-r--r-- | llvm/tools/opt/opt.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index c1e120af540..86fbed70036 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -25,6 +25,7 @@ #include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/IRPrintingPasses.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/LegacyPassNameParser.h" @@ -345,6 +346,18 @@ int main(int argc, char **argv) { return 1; } + // Strip debug info before running the verifier. + if (StripDebug) + StripDebugInfo(*M); + + // Immediately run the verifier to catch any problems before starting up the + // pass pipelines. Otherwise we can crash on broken code during + // doInitialization(). + if (!NoVerify && verifyModule(*M, &errs())) { + errs() << argv[0] << ": " << InputFilename << ": error: does not verify\n"; + return 1; + } + // If we are supposed to override the target triple, do so now. if (!TargetTriple.empty()) M->setTargetTriple(Triple::normalize(TargetTriple)); @@ -449,10 +462,6 @@ int main(int argc, char **argv) { NoOutput = true; } - // If the -strip-debug command line option was specified, add it. - if (StripDebug) - addPass(Passes, createStripSymbolsPass(true)); - // Create a new optimization pass for each one specified on the command line for (unsigned i = 0; i < PassList.size(); ++i) { if (StandardLinkOpts && |