diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 0d04b2563fe..85e2a89504d 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -27,10 +27,18 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" #include #include using namespace llvm; +namespace { + cl::opt + KeepMain("keep-main", + cl::desc("Force function reduction to keep main"), + cl::init(false)); +} + namespace llvm { class ReducePassList : public ListReducer { BugDriver &BD; @@ -109,6 +117,11 @@ namespace llvm { } bool ReduceCrashingFunctions::TestFuncs(std::vector &Funcs) { + + //if main isn't present, claim there is no problem + if (KeepMain && find(Funcs.begin(), Funcs.end(), BD.getProgram()->getMainFunction()) == Funcs.end()) + return false; + // Clone the program to try hacking it apart... Module *M = CloneModule(BD.getProgram());