[llvm-commits] CVS: llvm/tools/bugpoint/OptimizerDriver.cpp

Bill Wendling isanbard at gmail.com
Tue Nov 28 16:20:27 PST 2006



Changes in directory llvm/tools/bugpoint:

OptimizerDriver.cpp updated: 1.46 -> 1.47
---
Log message:

Replacing std::iostreams with llvm iostreams. Some of these changes involve
adding a temporary wrapper around the ostream to make it friendly to
functions expecting an LLVM stream. This should be fixed in the future.


---
Diffs of the changes:  (+25 -21)

 OptimizerDriver.cpp |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)


Index: llvm/tools/bugpoint/OptimizerDriver.cpp
diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.46 llvm/tools/bugpoint/OptimizerDriver.cpp:1.47
--- llvm/tools/bugpoint/OptimizerDriver.cpp:1.46	Wed Sep 13 23:20:17 2006
+++ llvm/tools/bugpoint/OptimizerDriver.cpp	Tue Nov 28 18:19:40 2006
@@ -27,6 +27,7 @@
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/System/Path.h"
 #include "llvm/System/Program.h"
 #include "llvm/Config/alloca.h"
@@ -55,7 +56,8 @@
   std::ofstream Out(Filename.c_str(), io_mode);
   if (!Out.good()) return true;
   try {
-    WriteBytecodeToFile(M ? M : Program, Out, /*compression=*/true);
+    llvm_ostream L(Out);
+    WriteBytecodeToFile(M ? M : Program, L, /*compression=*/true);
   } catch (...) {
     return true;
   }
@@ -72,15 +74,15 @@
   //
   std::string Filename = "bugpoint-" + ID + ".bc";
   if (writeProgramToFile(Filename)) {
-    std::cerr <<  "Error opening file '" << Filename << "' for writing!\n";
+    llvm_cerr <<  "Error opening file '" << Filename << "' for writing!\n";
     return;
   }
 
-  std::cout << "Emitted bytecode to '" << Filename << "'\n";
+  llvm_cout << "Emitted bytecode to '" << Filename << "'\n";
   if (NoFlyer || PassesToRun.empty()) return;
-  std::cout << "\n*** You can reproduce the problem with: ";
-  std::cout << "opt " << Filename << " ";
-  std::cout << getPassesString(PassesToRun) << "\n";
+  llvm_cout << "\n*** You can reproduce the problem with: ";
+  llvm_cout << "opt " << Filename << " ";
+  llvm_cout << getPassesString(PassesToRun) << "\n";
 }
 
 int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
@@ -89,7 +91,7 @@
                                std::ios::binary;
   std::ofstream OutFile(ChildOutput.c_str(), io_mode);
   if (!OutFile.good()) {
-    std::cerr << "Error opening bytecode file: " << ChildOutput << "\n";
+    llvm_cerr << "Error opening bytecode file: " << ChildOutput << "\n";
     return 1;
   }
 
@@ -101,14 +103,15 @@
     if (Passes[i]->getNormalCtor())
       PM.add(Passes[i]->getNormalCtor()());
     else
-      std::cerr << "Cannot create pass yet: " << Passes[i]->getPassName()
+      llvm_cerr << "Cannot create pass yet: " << Passes[i]->getPassName()
                 << "\n";
   }
   // Check that the module is well formed on completion of optimization
   PM.add(createVerifierPass());
 
   // Write bytecode out to disk as the last step...
-  PM.add(new WriteBytecodePass(&OutFile));
+  llvm_ostream L(OutFile);
+  PM.add(new WriteBytecodePass(&L));
 
   // Run all queued passes.
   PM.run(*Program);
@@ -128,11 +131,11 @@
                           std::string &OutputFilename, bool DeleteOutput,
                           bool Quiet) const {
   // setup the output file name
-  std::cout << std::flush;
+  llvm_cout << std::flush;
   sys::Path uniqueFilename("bugpoint-output.bc");
   std::string ErrMsg;
   if (uniqueFilename.makeUnique(true, &ErrMsg)) {
-    std::cerr << getToolName() << ": Error making unique filename: " 
+    llvm_cerr << getToolName() << ": Error making unique filename: " 
               << ErrMsg << "\n";
     return(1);
   }
@@ -141,7 +144,7 @@
   // set up the input file name
   sys::Path inputFilename("bugpoint-input.bc");
   if (inputFilename.makeUnique(true, &ErrMsg)) {
-    std::cerr << getToolName() << ": Error making unique filename: " 
+    llvm_cerr << getToolName() << ": Error making unique filename: " 
               << ErrMsg << "\n";
     return(1);
   }
@@ -149,10 +152,11 @@
                                std::ios::binary;
   std::ofstream InFile(inputFilename.c_str(), io_mode);
   if (!InFile.good()) {
-    std::cerr << "Error opening bytecode file: " << inputFilename << "\n";
+    llvm_cerr << "Error opening bytecode file: " << inputFilename << "\n";
     return(1);
   }
-  WriteBytecodeToFile(Program,InFile,false);
+  llvm_ostream L(InFile);
+  WriteBytecodeToFile(Program,L,false);
   InFile.close();
 
   // setup the child process' arguments
@@ -203,17 +207,17 @@
 
   if (!Quiet) {
     if (result == 0)
-      std::cout << "Success!\n";
+      llvm_cout << "Success!\n";
     else if (result > 0)
-      std::cout << "Exited with error code '" << result << "'\n";
+      llvm_cout << "Exited with error code '" << result << "'\n";
     else if (result < 0) {
       if (result == -1)
-        std::cout << "Execute failed: " << ErrMsg << "\n";
+        llvm_cout << "Execute failed: " << ErrMsg << "\n";
       else
-        std::cout << "Crashed with signal #" << abs(result) << "\n";
+        llvm_cout << "Crashed with signal #" << abs(result) << "\n";
     }
     if (result & 0x01000000)
-      std::cout << "Dumped core\n";
+      llvm_cout << "Dumped core\n";
   }
 
   // Was the child successful?
@@ -231,7 +235,7 @@
   std::string BytecodeResult;
   if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) {
     if (AutoDebugCrashes) {
-      std::cerr << " Error running this sequence of passes"
+      llvm_cerr << " Error running this sequence of passes"
                 << " on the input program!\n";
       delete OldProgram;
       EmitProgressBytecode("pass-error",  false);
@@ -246,7 +250,7 @@
 
   Module *Ret = ParseInputFile(BytecodeResult);
   if (Ret == 0) {
-    std::cerr << getToolName() << ": Error reading bytecode file '"
+    llvm_cerr << getToolName() << ": Error reading bytecode file '"
               << BytecodeResult << "'!\n";
     exit(1);
   }






More information about the llvm-commits mailing list