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

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 14 15:54:02 PDT 2003


Changes in directory llvm/tools/bugpoint:

BugDriver.cpp updated: 1.16 -> 1.17
Miscompilation.cpp updated: 1.15 -> 1.16

---
Log message:

Eliminate the bugpoint -mode option, by making bugpoint automatically infer the root of all of your problems


---
Diffs of the changes:  (+22 -36)

Index: llvm/tools/bugpoint/BugDriver.cpp
diff -u llvm/tools/bugpoint/BugDriver.cpp:1.16 llvm/tools/bugpoint/BugDriver.cpp:1.17
--- llvm/tools/bugpoint/BugDriver.cpp:1.16	Mon Oct 13 16:04:26 2003
+++ llvm/tools/bugpoint/BugDriver.cpp	Tue Oct 14 15:52:55 2003
@@ -27,14 +27,6 @@
   cl::opt<std::string> 
   OutputFile("output", cl::desc("Specify a reference program output "
                                 "(for miscompilation detection)"));
-
-  enum DebugType { DebugCompile, DebugCodegen };
-  cl::opt<DebugType>
-  DebugMode("mode", cl::desc("Debug mode for bugpoint:"), cl::Prefix,
-            cl::values(clEnumValN(DebugCompile, "compile", "  Compilation"),
-                       clEnumValN(DebugCodegen, "codegen", "  Code generation"),
-                       0),
-            cl::init(DebugCompile));
 }
 
 /// getPassesString - Turn a list of passes into a string which indicates the
@@ -134,8 +126,6 @@
       return debugCrash();
   }
 
-  std::cout << "Checking for a miscompilation...\n";
-
   // Set up the execution environment, selecting a method to run LLVM bytecode.
   if (initializeExecutionEnvironment()) return true;
 
@@ -146,33 +136,36 @@
   bool CreatedOutput = false;
   if (ReferenceOutputFile.empty()) {
     std::cout << "Generating reference output from raw program...";
-    if (DebugCodegen) {
-      ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
-    } else {
-      ReferenceOutputFile = executeProgram("bugpoint.reference.out");
-    }
+    ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
     CreatedOutput = true;
     std::cout << "Reference output is: " << ReferenceOutputFile << "\n";
-  } 
+  }
 
-  bool Result;
-  switch (DebugMode) {
-  default: assert(0 && "Bad value for DebugMode!");
-  case DebugCompile:
+  // Make sure the reference output file gets deleted on exit from this
+  // function, if appropriate.
+  struct Remover {
+    bool DeleteIt; const std::string &Filename;
+    Remover(bool deleteIt, const std::string &filename)
+      : DeleteIt(deleteIt), Filename(filename) {}
+    ~Remover() {
+      if (DeleteIt) removeFile(Filename);
+    }
+  } RemoverInstance(CreatedOutput, ReferenceOutputFile);
+
+  // Diff the output of the raw program against the reference output.  If it
+  // matches, then we have a miscompilation bug.
+  std::cout << "*** Checking the code generator...\n";
+  if (!diffProgram()) {
     std::cout << "\n*** Debugging miscompilation!\n";
-    Result = debugMiscompilation();
-    break;
-  case DebugCodegen:
-    std::cout << "Debugging code generator problem!\n";
-    Result = debugCodeGenerator();
+    return debugMiscompilation();
   }
 
-  if (CreatedOutput) removeFile(ReferenceOutputFile);
-  return Result;
+  std::cout << "\n*** Input program does not match reference diff!\n";
+  std::cout << "Debugging code generator problem!\n";
+  return debugCodeGenerator();
 }
 
-void BugDriver::PrintFunctionList(const std::vector<Function*> &Funcs)
-{
+void BugDriver::PrintFunctionList(const std::vector<Function*> &Funcs) {
   for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
     if (i) std::cout << ", ";
     std::cout << Funcs[i]->getName();


Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.15 llvm/tools/bugpoint/Miscompilation.cpp:1.16
--- llvm/tools/bugpoint/Miscompilation.cpp:1.15	Thu Aug  7 16:42:28 2003
+++ llvm/tools/bugpoint/Miscompilation.cpp	Tue Oct 14 15:52:55 2003
@@ -261,13 +261,6 @@
 /// input.
 ///
 bool BugDriver::debugMiscompilation() {
-
-  if (diffProgram()) {
-    std::cout << "\n*** Input program does not match reference diff!\n"
-              << "    Must be problem with input source!\n";
-    return false;  // Problem found
-  }
-
   // Make sure something was miscompiled...
   if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
     std::cerr << "*** Optimized program matches reference output!  No problem "





More information about the llvm-commits mailing list