Add save-temps option to bugpoint to keep temporary stuff.
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 5 Aug 2009 09:32:10 +0000 (09:32 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 5 Aug 2009 09:32:10 +0000 (09:32 +0000)
Patch by Sandeep Patel

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78183 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.cpp
tools/bugpoint/ExecutionDriver.cpp
tools/bugpoint/ToolRunner.cpp
tools/bugpoint/ToolRunner.h

index 0934206fde1bb9cd883df93dfeed8130d7493966..c3cc389a280f5bfdc4df48222abfe60c0f11cc1d 100644 (file)
@@ -196,7 +196,7 @@ bool BugDriver::run() {
   // Make sure the reference output file gets deleted on exit from this
   // function, if appropriate.
   sys::Path ROF(ReferenceOutputFile);
-  FileRemover RemoverInstance(ROF, CreatedOutput);
+  FileRemover RemoverInstance(ROF, CreatedOutput && !SaveTemps);
 
   // Diff the output of the raw program against the reference output.  If it
   // matches, then we assume there is a miscompilation bug and try to 
index 4122c9507c70289b1f3b152118666507c6cfb0b2..ceaf8f498bc64c4979f24e67ecd337ed162eb416 100644 (file)
@@ -288,7 +288,7 @@ void BugDriver::compileProgram(Module *M) {
   }
 
     // Remove the temporary bitcode file when we are done.
-  FileRemover BitcodeFileRemover(BitcodeFile);
+  FileRemover BitcodeFileRemover(BitcodeFile, !SaveTemps);
 
   // Actually compile the program!
   Interpreter->compileProgram(BitcodeFile.toString());
@@ -328,7 +328,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
 
   // Remove the temporary bitcode file when we are done.
   sys::Path BitcodePath (BitcodeFile);
-  FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode);
+  FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode && !SaveTemps);
 
   if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
 
index ef07079af309f84ac5ce7df676681c30e06fb1cc..81314a85c389d7c85fd21f1ce69ae867a02b8b0d 100644 (file)
 #include <sstream>
 using namespace llvm;
 
+namespace llvm {
+  cl::opt<bool>
+  SaveTemps("save-temps", cl::init(false), cl::desc("Save temporary files"));
+}
+
 namespace {
   cl::opt<std::string>
   RemoteClient("remote-client",
@@ -395,7 +400,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
 
   sys::Path OutputAsmFile;
   OutputCode(Bitcode, OutputAsmFile);
-  FileRemover OutFileRemover(OutputAsmFile);
+  FileRemover OutFileRemover(OutputAsmFile, !SaveTemps);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
   GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
@@ -560,7 +565,7 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
   sys::Path OutputCFile;
   OutputCode(Bitcode, OutputCFile);
 
-  FileRemover CFileRemove(OutputCFile);
+  FileRemover CFileRemove(OutputCFile, !SaveTemps);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
   GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
@@ -726,7 +731,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
         errs() << "\n";
         );
 
-  FileRemover OutputBinaryRemover(OutputBinary);
+  FileRemover OutputBinaryRemover(OutputBinary, !SaveTemps);
 
   if (RemoteClientPath.isEmpty()) {
     DEBUG(errs() << "<run locally>";);
index 721f66c126cced43f2d887ac000c543657db1f13..58daef00a8c25fd728fcd216bfea0f0b7e24372b 100644 (file)
 #ifndef BUGPOINT_TOOLRUNNER_H
 #define BUGPOINT_TOOLRUNNER_H
 
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/SystemUtils.h"
 #include <exception>
 #include <vector>
 
 namespace llvm {
 
+extern cl::opt<bool> SaveTemps;
+
 class CBE;
 class LLC;