Add -output-prefix option to bugpoint (to change the default output name).
authorDaniel Dunbar <daniel@zuster.org>
Mon, 7 Sep 2009 19:26:11 +0000 (19:26 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 7 Sep 2009 19:26:11 +0000 (19:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81154 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/ExecutionDriver.cpp
tools/bugpoint/ExtractFunction.cpp
tools/bugpoint/Miscompilation.cpp
tools/bugpoint/OptimizerDriver.cpp

index 72b971764197ee73a7ceadddb41ae29b4a851cee..feda331177b166a62536526ccf85c0e882a029ca 100644 (file)
@@ -100,6 +100,10 @@ namespace llvm {
   cl::list<std::string>
   InputArgv("args", cl::Positional, cl::desc("<program arguments>..."),
             cl::ZeroOrMore, cl::PositionalEatsArgs);
+
+  cl::opt<std::string>
+  OutputPrefix("output-prefix", cl::init("bugpoint"),
+            cl::desc("Prefix to use for outputs (default: 'bugpoint')"));
 }
 
 namespace {
@@ -274,7 +278,7 @@ bool BugDriver::initializeExecutionEnvironment() {
 ///
 void BugDriver::compileProgram(Module *M) {
   // Emit the program to a bitcode file...
-  sys::Path BitcodeFile ("bugpoint-test-program.bc");
+  sys::Path BitcodeFile (OutputPrefix + "-test-program.bc");
   std::string ErrMsg;
   if (BitcodeFile.makeUnique(true,&ErrMsg)) {
     errs() << ToolName << ": Error making unique filename: " << ErrMsg 
@@ -310,7 +314,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
   std::string ErrMsg;
   if (BitcodeFile.empty()) {
     // Emit the program to a bitcode file...
-    sys::Path uniqueFilename("bugpoint-test-program.bc");
+    sys::Path uniqueFilename(OutputPrefix + "-test-program.bc");
     if (uniqueFilename.makeUnique(true, &ErrMsg)) {
       errs() << ToolName << ": Error making unique filename: "
              << ErrMsg << "!\n";
@@ -330,7 +334,7 @@ std::string BugDriver::executeProgram(std::string OutputFile,
   sys::Path BitcodePath (BitcodeFile);
   FileRemover BitcodeFileRemover(BitcodePath, CreatedBitcode && !SaveTemps);
 
-  if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
+  if (OutputFile.empty()) OutputFile = OutputPrefix + "-execution-output";
 
   // Check to see if this is a valid output filename...
   sys::Path uniqueFile(OutputFile);
index a54f51b673acd9d713b7eed6a4d6216b340f813b..df9277c10ffcf6331df5b315487fd3420e1a2d23 100644 (file)
@@ -37,6 +37,7 @@ using namespace llvm;
 
 namespace llvm {
   bool DisableSimplifyCFG = false;
+  extern cl::opt<std::string> OutputPrefix;
 } // End llvm namespace
 
 namespace {
@@ -324,7 +325,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
                                                  Module *M) {
   char *ExtraArg = NULL;
 
-  sys::Path uniqueFilename("bugpoint-extractblocks");
+  sys::Path uniqueFilename(OutputPrefix + "-extractblocks");
   std::string ErrMsg;
   if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
     outs() << "*** Basic Block extraction failed!\n";
index 57a4fc717fe641b59e4bad7231a7278e4c8f37d3..e1aeaf8efed6993782802c65ec83aa467871058e 100644 (file)
@@ -30,6 +30,7 @@
 using namespace llvm;
 
 namespace llvm {
+  extern cl::opt<std::string> OutputPrefix;
   extern cl::list<std::string> InputArgv;
 }
 
@@ -301,12 +302,15 @@ static bool ExtractLoops(BugDriver &BD,
              << " Please report a bug!\n";
       errs() << "      Continuing on with un-loop-extracted version.\n";
 
-      BD.writeProgramToFile("bugpoint-loop-extract-fail-tno.bc", ToNotOptimize);
-      BD.writeProgramToFile("bugpoint-loop-extract-fail-to.bc", ToOptimize);
-      BD.writeProgramToFile("bugpoint-loop-extract-fail-to-le.bc",
+      BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-tno.bc",
+                            ToNotOptimize);
+      BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to.bc",
+                            ToOptimize);
+      BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to-le.bc",
                             ToOptimizeLoopExtracted);
 
-      errs() << "Please submit the bugpoint-loop-extract-fail-*.bc files.\n";
+      errs() << "Please submit the " 
+             << OutputPrefix << "-loop-extract-fail-*.bc files.\n";
       delete ToOptimize;
       delete ToNotOptimize;
       delete ToOptimizeLoopExtracted;
index 5afb2205e4219d2c8814aa03ebcf6d9a468ca4dd..9f712e097a74b6386177bba9bde8030faa76cfd0 100644 (file)
@@ -37,6 +37,9 @@
 #include <fstream>
 using namespace llvm;
 
+namespace llvm {
+  extern cl::opt<std::string> OutputPrefix;
+}
 
 namespace {
   // ChildOutput - This option captures the name of the child output file that
@@ -68,7 +71,7 @@ void BugDriver::EmitProgressBitcode(const std::string &ID, bool NoFlyer) {
   // Output the input to the current pass to a bitcode file, emit a message
   // telling the user how to reproduce it: opt -foo blah.bc
   //
-  std::string Filename = "bugpoint-" + ID + ".bc";
+  std::string Filename = OutputPrefix + "-" + ID + ".bc";
   if (writeProgramToFile(Filename)) {
     errs() <<  "Error opening file '" << Filename << "' for writing!\n";
     return;
@@ -129,7 +132,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
                           const char * const *ExtraArgs) const {
   // setup the output file name
   outs().flush();
-  sys::Path uniqueFilename("bugpoint-output.bc");
+  sys::Path uniqueFilename(OutputPrefix + "-output.bc");
   std::string ErrMsg;
   if (uniqueFilename.makeUnique(true, &ErrMsg)) {
     errs() << getToolName() << ": Error making unique filename: "
@@ -139,7 +142,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
   OutputFilename = uniqueFilename.str();
 
   // set up the input file name
-  sys::Path inputFilename("bugpoint-input.bc");
+  sys::Path inputFilename(OutputPrefix + "-input.bc");
   if (inputFilename.makeUnique(true, &ErrMsg)) {
     errs() << getToolName() << ": Error making unique filename: "
            << ErrMsg << "\n";