For PR351:
Generally, remove use of fork/exec from bugpoint in favor of the portable
sys::Program::ExecuteAndWait method. This change requires two new options
to bugpoint to tell it that it is running in "child" mode. In this mode,
it reads its input and runs the passes. The result code signals to the
parent instance of bugpoint what happened (success, fail, crash).

This change should make bugpoint usable on Win32 systems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24961 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index 192ed52..565a382 100644
--- a/tools/bugpoint/BugDriver.h
+++ b/tools/bugpoint/BugDriver.h
@@ -47,13 +47,14 @@
   AbstractInterpreter *Interpreter;   // How to run the program
   CBE *cbe;
   GCC *gcc;
+  bool run_as_child;
 
   // FIXME: sort out public/private distinctions...
   friend class ReducePassList;
   friend class ReduceMisCodegenFunctions;
 
 public:
-  BugDriver(const char *toolname);
+  BugDriver(const char *toolname, bool as_child);
 
   const std::string &getToolName() const { return ToolName; }
 
@@ -71,7 +72,8 @@
   }
 
   /// run - The top level method that is invoked after all of the instance
-  /// variables are set up from command line arguments.
+  /// variables are set up from command line arguments. The \p as_child argument
+  /// indicates whether the driver is to run in parent mode or child mode.
   ///
   bool run();
 
@@ -249,6 +251,9 @@
     return runPasses(PassesToRun, Filename, DeleteOutput);
   }
 
+  /// runAsChild - The actual "runPasses" guts that runs in a child process.
+  int runPassesAsChild(const std::vector<const PassInfo*> &PassesToRun);
+
   /// initializeExecutionEnvironment - This method is used to set up the
   /// environment for executing LLVM programs.
   ///