From 0a002569003fd23a4e117fe54a9bb8a6673b86da Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 14 Mar 2004 21:21:57 +0000 Subject: [PATCH] Add a new "AutoDebugCrashes" option git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12396 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/bugpoint/BugDriver.h | 7 +++++-- tools/bugpoint/OptimizerDriver.cpp | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index b1cc3e830ba..f5ef51763e3 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -192,8 +192,11 @@ public: /// runPassesOn - Carefully run the specified set of pass on the specified /// module, returning the transformed module on success, or a null pointer on - /// failure. - Module *runPassesOn(Module *M, const std::vector &Passes); + /// failure. If AutoDebugCrashes is set to true, then bugpoint will + /// automatically attempt to track down a crashing pass if one exists, and + /// this method will never return null. + Module *runPassesOn(Module *M, const std::vector &Passes, + bool AutoDebugCrashes = false); /// runPasses - Run the specified passes on Program, outputting a bytecode /// file and writting the filename into OutputFile if successful. If the diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index d741265606a..14ca7c832c3 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -16,6 +16,7 @@ //===----------------------------------------------------------------------===// #include "BugDriver.h" +#include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/WriteBytecodePass.h" @@ -166,11 +167,20 @@ bool BugDriver::runPasses(const std::vector &Passes, /// module, returning the transformed module on success, or a null pointer on /// failure. Module *BugDriver::runPassesOn(Module *M, - const std::vector &Passes) { + const std::vector &Passes, + bool AutoDebugCrashes) { Module *OldProgram = swapProgramIn(M); std::string BytecodeResult; - if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) + if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) { + if (AutoDebugCrashes) { + std::cerr << " Error running this sequence of passes" + << " on the input program!\n"; + delete OldProgram; + EmitProgressBytecode("pass-error", false); + exit(debugOptimizerCrash()); + } return 0; + } // Restore the current program. swapProgramIn(OldProgram);