From 86c006a971eb6fab6bd4923ff7ec1c0bc9c28f74 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Wed, 5 Aug 2009 09:32:10 +0000 Subject: Add save-temps option to bugpoint to keep temporary stuff. 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 | 2 +- tools/bugpoint/ExecutionDriver.cpp | 4 ++-- tools/bugpoint/ToolRunner.cpp | 11 ++++++++--- tools/bugpoint/ToolRunner.h | 3 +++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index 0934206fde..c3cc389a28 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -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 diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 4122c9507c..ceaf8f498b 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -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"; diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index ef07079af3..81314a85c3 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -22,6 +22,11 @@ #include using namespace llvm; +namespace llvm { + cl::opt + SaveTemps("save-temps", cl::init(false), cl::desc("Save temporary files")); +} + namespace { cl::opt 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 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 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() << "";); diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h index 721f66c126..58daef00a8 100644 --- a/tools/bugpoint/ToolRunner.h +++ b/tools/bugpoint/ToolRunner.h @@ -17,12 +17,15 @@ #ifndef BUGPOINT_TOOLRUNNER_H #define BUGPOINT_TOOLRUNNER_H +#include "llvm/Support/CommandLine.h" #include "llvm/Support/SystemUtils.h" #include #include namespace llvm { +extern cl::opt SaveTemps; + class CBE; class LLC; -- cgit v1.2.3