minor cleanups. Add provisions for a new standard BLOCKINFO_BLOCK
[oota-llvm.git] / tools / bugpoint / ExecutionDriver.cpp
index dedf91eb035b09497512250637072843d19bab64..f4a072b14aede9f0649b7c3e7ca348bc9f6dbe4e 100644 (file)
@@ -28,7 +28,7 @@ namespace {
   // for miscompilation.
   //
   enum OutputType {
-    AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug
+    AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug, LLC_Safe
   };
 
   cl::opt<double>
@@ -47,6 +47,7 @@ namespace {
                             clEnumValN(RunLLC, "run-llc", "Compile with LLC"),
                             clEnumValN(RunCBE, "run-cbe", "Compile with CBE"),
                             clEnumValN(CBE_bug,"cbe-bug", "Find CBE bugs"),
+                            clEnumValN(LLC_Safe, "llc-safe", "Use LLC for all"),
                             clEnumValEnd),
                  cl::init(AutoPick));
 
@@ -55,6 +56,11 @@ namespace {
                    cl::desc("Assume nonzero exit code is failure (default on)"),
                        cl::init(true));
 
+  cl::opt<bool>
+  AppendProgramExitCode("append-exit-code",
+      cl::desc("Append the exit code to the output so it gets diff'd too"),
+      cl::init(false));
+
   cl::opt<std::string>
   InputFile("input", cl::init("/dev/null"),
             cl::desc("Filename to pipe in as stdin (default: /dev/null)"));
@@ -133,6 +139,10 @@ bool BugDriver::initializeExecutionEnvironment() {
     Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
                                                  &ToolArgv);
     break;
+  case LLC_Safe:
+    Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
+                                                 &ToolArgv);
+    break;
   case RunCBE:
   case CBE_bug:
     Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
@@ -148,8 +158,9 @@ bool BugDriver::initializeExecutionEnvironment() {
   if (InterpreterSel == RunCBE) {
     // We already created a CBE, reuse it.
     cbe = Interpreter;
-  } else if (InterpreterSel == CBE_bug) {
-    // We want to debug the CBE itself.  Use LLC as the 'known-good' compiler.
+  } else if (InterpreterSel == CBE_bug || InterpreterSel == LLC_Safe) {
+    // We want to debug the CBE itself or LLC is known-good.  Use LLC as the
+    // 'known-good' compiler.
     std::vector<std::string> ToolArgs;
     ToolArgs.push_back("--relocation-model=pic");
     cbe = AbstractInterpreter::createLLC(getToolName(), Message, &ToolArgs);
@@ -252,11 +263,11 @@ std::string BugDriver::executeProgram(std::string OutputFile,
       InterpreterSel == CBE_bug)
     RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
                                 OutputFile, AdditionalLinkerArgs, SharedObjs, 
-                                Timeout);
+                                Timeout, MemoryLimit);
   else 
     RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
                                 OutputFile, std::vector<std::string>(), 
-                                SharedObjs, Timeout);
+                                SharedObjs, Timeout, MemoryLimit);
 
   if (RetVal == -1) {
     std::cerr << "<timeout>";
@@ -271,6 +282,12 @@ std::string BugDriver::executeProgram(std::string OutputFile,
     }
   }
 
+  if (AppendProgramExitCode) {
+    std::ofstream outFile(OutputFile.c_str(), std::ios_base::app);
+    outFile << "exit " << RetVal << '\n';
+    outFile.close();
+  }
+
   if (ProgramExitedNonzero != 0)
     *ProgramExitedNonzero = (RetVal != 0);