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

Reid Spencer reid at x10sys.com
Tue Dec 14 17:53:19 PST 2004



Changes in directory llvm/tools/bugpoint:

ExecutionDriver.cpp updated: 1.48 -> 1.49
Miscompilation.cpp updated: 1.56 -> 1.57
OptimizerDriver.cpp updated: 1.24 -> 1.25
---
Log message:

For PR351: http://llvm.cs.uiuc.edu/PR351 :
* Convert use of getUniqueFilename to sys::Path::makeUnique();


---
Diffs of the changes:  (+34 -20)

Index: llvm/tools/bugpoint/ExecutionDriver.cpp
diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.48 llvm/tools/bugpoint/ExecutionDriver.cpp:1.49
--- llvm/tools/bugpoint/ExecutionDriver.cpp:1.48	Wed Sep  1 17:55:37 2004
+++ llvm/tools/bugpoint/ExecutionDriver.cpp	Tue Dec 14 19:53:08 2004
@@ -152,18 +152,19 @@
 ///
 void BugDriver::compileProgram(Module *M) {
   // Emit the program to a bytecode file...
-  std::string BytecodeFile = getUniqueFilename("bugpoint-test-program.bc");
-  if (writeProgramToFile(BytecodeFile, M)) {
+  sys::Path BytecodeFile ("bugpoint-test-program.bc");
+  BytecodeFile.makeUnique();
+  if (writeProgramToFile(BytecodeFile.toString(), M)) {
     std::cerr << ToolName << ": Error emitting bytecode to file '"
               << BytecodeFile << "'!\n";
     exit(1);
   }
 
     // Remove the temporary bytecode file when we are done.
-  FileRemover BytecodeFileRemover(BytecodeFile);
+  FileRemover BytecodeFileRemover(BytecodeFile.toString());
 
   // Actually compile the program!
-  Interpreter->compileProgram(BytecodeFile);
+  Interpreter->compileProgram(BytecodeFile.toString());
 }
 
 
@@ -181,7 +182,9 @@
   bool CreatedBytecode = false;
   if (BytecodeFile.empty()) {
     // Emit the program to a bytecode file...
-    BytecodeFile = getUniqueFilename("bugpoint-test-program.bc");
+    sys::Path uniqueFilename("bugpoint-test-program.bc");
+    uniqueFilename.makeUnique();
+    BytecodeFile = uniqueFilename.toString();
 
     if (writeProgramToFile(BytecodeFile, Program)) {
       std::cerr << ToolName << ": Error emitting bytecode to file '"
@@ -197,7 +200,9 @@
   if (OutputFile.empty()) OutputFile = "bugpoint-execution-output";
 
   // Check to see if this is a valid output filename...
-  OutputFile = getUniqueFilename(OutputFile);
+  sys::Path uniqueFile(OutputFile);
+  uniqueFile.makeUnique();
+  OutputFile = uniqueFile.toString();
 
   // Figure out which shared objects to run, if any.
   std::vector<std::string> SharedObjs(AdditionalSOs);


Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.56 llvm/tools/bugpoint/Miscompilation.cpp:1.57
--- llvm/tools/bugpoint/Miscompilation.cpp:1.56	Sun Dec 12 21:01:03 2004
+++ llvm/tools/bugpoint/Miscompilation.cpp	Tue Dec 14 19:53:08 2004
@@ -733,33 +733,35 @@
 static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
   CleanupAndPrepareModules(BD, Test, Safe);
 
-  std::string TestModuleBC = getUniqueFilename("bugpoint.test.bc");
-  if (BD.writeProgramToFile(TestModuleBC, Test)) {
+  sys::Path TestModuleBC("bugpoint.test.bc");
+  TestModuleBC.makeUnique();
+  if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) {
     std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting.";
     exit(1);
   }
   delete Test;
 
   // Make the shared library
-  std::string SafeModuleBC = getUniqueFilename("bugpoint.safe.bc");
+  sys::Path SafeModuleBC("bugpoint.safe.bc");
+  SafeModuleBC.makeUnique();
 
-  if (BD.writeProgramToFile(SafeModuleBC, Safe)) {
+  if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) {
     std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
     exit(1);
   }
-  std::string SharedObject = BD.compileSharedObject(SafeModuleBC);
+  std::string SharedObject = BD.compileSharedObject(SafeModuleBC.toString());
   delete Safe;
 
   // Run the code generator on the `Test' code, loading the shared library.
   // The function returns whether or not the new output differs from reference.
-  int Result = BD.diffProgram(TestModuleBC, SharedObject, false);
+  int Result = BD.diffProgram(TestModuleBC.toString(), SharedObject, false);
 
   if (Result)
     std::cerr << ": still failing!\n";
   else
     std::cerr << ": didn't fail.\n";
-  removeFile(TestModuleBC);
-  removeFile(SafeModuleBC);
+  removeFile(TestModuleBC.toString());
+  removeFile(SafeModuleBC.toString());
   removeFile(SharedObject);
 
   return Result;
@@ -791,20 +793,24 @@
   // Condition the modules
   CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen);
 
-  std::string TestModuleBC = getUniqueFilename("bugpoint.test.bc");
-  if (writeProgramToFile(TestModuleBC, ToCodeGen)) {
+  sys::Path TestModuleBC("bugpoint.test.bc");
+  TestModuleBC.makeUnique();
+
+  if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) {
     std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting.";
     exit(1);
   }
   delete ToCodeGen;
 
   // Make the shared library
-  std::string SafeModuleBC = getUniqueFilename("bugpoint.safe.bc");
-  if (writeProgramToFile(SafeModuleBC, ToNotCodeGen)) {
+  sys::Path SafeModuleBC("bugpoint.safe.bc");
+  SafeModuleBC.makeUnique();
+
+  if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) {
     std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
     exit(1);
   }
-  std::string SharedObject = compileSharedObject(SafeModuleBC);
+  std::string SharedObject = compileSharedObject(SafeModuleBC.toString());
   delete ToNotCodeGen;
 
   std::cout << "You can reproduce the problem with the command line: \n";


Index: llvm/tools/bugpoint/OptimizerDriver.cpp
diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.24 llvm/tools/bugpoint/OptimizerDriver.cpp:1.25
--- llvm/tools/bugpoint/OptimizerDriver.cpp:1.24	Sat Nov  6 23:43:51 2004
+++ llvm/tools/bugpoint/OptimizerDriver.cpp	Tue Dec 14 19:53:08 2004
@@ -22,6 +22,7 @@
 #include "llvm/Bytecode/WriteBytecodePass.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/System/Path.h"
 #include <fstream>
 #include <unistd.h>
 #include <sys/types.h>
@@ -114,7 +115,9 @@
                           std::string &OutputFilename, bool DeleteOutput,
 			  bool Quiet) const{
   std::cout << std::flush;
-  OutputFilename = getUniqueFilename("bugpoint-output.bc");
+  sys::Path uniqueFilename("bugpoint-output.bc");
+  uniqueFilename.makeUnique();
+  OutputFilename = uniqueFilename.toString();
 
   pid_t child_pid;
   switch (child_pid = fork()) {






More information about the llvm-commits mailing list