For transforms the behave differently if main goes away, add an option to prevent...
authorAndrew Lenharth <andrewl@lenharth.org>
Sun, 5 Mar 2006 22:21:36 +0000 (22:21 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Sun, 5 Mar 2006 22:21:36 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26557 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/CrashDebugger.cpp

index 0d04b2563fe7b9de1ec57aa9451841da8246fc0d..85e2a89504d8bef347aa3129ecbba3dc53ec5b00 100644 (file)
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/CommandLine.h"
 #include <fstream>
 #include <set>
 using namespace llvm;
 
+namespace {
+  cl::opt<bool>
+  KeepMain("keep-main",
+           cl::desc("Force function reduction to keep main"),
+           cl::init(false));
+}
+
 namespace llvm {
   class ReducePassList : public ListReducer<const PassInfo*> {
     BugDriver &BD;
@@ -109,6 +117,11 @@ namespace llvm {
 }
 
 bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &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());