[llvm-commits] CVS: llvm/tools/bugpoint/CodeGeneratorBug.cpp ListReducer.h Miscompilation.cpp

Misha Brukman brukman at cs.uiuc.edu
Wed Jul 30 15:17:05 PDT 2003


Changes in directory llvm/tools/bugpoint:

CodeGeneratorBug.cpp updated: 1.5 -> 1.6
ListReducer.h updated: 1.3 -> 1.4
Miscompilation.cpp updated: 1.10 -> 1.11

---
Log message:

CodeGeneratorBug.cpp:
* Temporarily externing InputArgv to print it out for the benefit of LLI command
  needed to reproduce the result.
* Print out the list of functions currently being tested
* ListReducer now returns a bool if there was a failure, so test for it
 
ListReducer.h:
* Handle the case where there is no problem by returning true if failure is
  found. Also correctly handles the case when there is only 1 pass/function.

Miscompilation.cpp:
* ListReducer now returns a bool if there was a failure, so test for it


---
Diffs of the changes:

Index: llvm/tools/bugpoint/CodeGeneratorBug.cpp
diff -u llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.5 llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.6
--- llvm/tools/bugpoint/CodeGeneratorBug.cpp:1.5	Tue Jul 29 11:02:28 2003
+++ llvm/tools/bugpoint/CodeGeneratorBug.cpp	Wed Jul 30 15:15:56 2003
@@ -20,11 +20,14 @@
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 #include "llvm/Transforms/Utils/Linker.h"
+#include "Support/CommandLine.h"
 #include "Support/Statistic.h"
 #include "Support/StringExtras.h"
 #include <algorithm>
 #include <set>
 
+extern cl::list<std::string> InputArgv;
+
 class ReduceMisCodegenFunctions : public ListReducer<Function*> {
   BugDriver &BD;
 public:
@@ -47,10 +50,9 @@
 bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
                                           bool KeepFiles)
 {
-  DEBUG(std::cerr << "Test functions are:\n");
-  for (std::vector<Function*>::const_iterator I = Funcs.begin(),E = Funcs.end();
-       I != E; ++I)
-    DEBUG(std::cerr << "\t" << (*I)->getName() << "\n");
+  std::cout << "Testing functions: ";
+  BD.PrintFunctionList(Funcs);
+  std::cout << "\t";
 
   // Clone the module for the two halves of the program we want.
   Module *SafeModule = CloneModule(BD.Program);
@@ -150,7 +152,7 @@
             // cast the result from the resolver to correctly-typed function
             CastInst *castResolver =
               new CastInst(resolve, PointerType::get(F->getFunctionType()),
-                           "", Inst);
+                           "resolverCast", Inst);
             // actually use the resolved function
             Inst->replaceUsesOfWith(F, castResolver);
           } else {
@@ -227,8 +229,12 @@
   if (KeepFiles) {
     std::cout << "You can reproduce the problem with the command line: \n"
               << (BD.isExecutingJIT() ? "lli" : "llc")
-              << " -load " << SharedObject << " " << TestModuleBC
-              << "\n";
+              << " -load " << SharedObject << " " << TestModuleBC;
+    for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
+      std::cout << " " << InputArgv[i];
+    std::cout << "\n";
+    std::cout << "The shared object " << SharedObject << " was created from "
+              << SafeModuleBC << ", using `dis -c'.\n";
   } else {
     removeFile(TestModuleBC);
     removeFile(SafeModuleBC);
@@ -346,7 +352,11 @@
   DisambiguateGlobalSymbols(Program);
 
   // Do the reduction...
-  ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions);
+  if (!ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions)) {
+    std::cerr << "*** Execution matches reference output!  No problem "
+	      << "detected...\nbugpoint can't help you with your problem!\n";
+    return false;
+  }
 
   std::cout << "\n*** The following functions are being miscompiled: ";
   PrintFunctionList(MisCodegenFunctions);


Index: llvm/tools/bugpoint/ListReducer.h
diff -u llvm/tools/bugpoint/ListReducer.h:1.3 llvm/tools/bugpoint/ListReducer.h:1.4
--- llvm/tools/bugpoint/ListReducer.h:1.3	Thu Apr 24 22:16:33 2003
+++ llvm/tools/bugpoint/ListReducer.h	Wed Jul 30 15:15:56 2003
@@ -30,7 +30,24 @@
   // list while still maintaining the "test" property.  This is the core of the
   // "work" that bugpoint does.
   //
-  void reduceList(std::vector<ElTy> &TheList) {
+  bool reduceList(std::vector<ElTy> &TheList) {
+    std::vector<ElTy> empty;
+    switch (doTest(TheList, empty)) {
+    case KeepPrefix:
+      if (TheList.size() == 1) // we are done, it's the base case and it fails
+        return true;
+      else 
+        break; // there's definitely an error, but we need to narrow it down
+
+    case KeepSuffix:
+      // cannot be reached!
+      std::cerr << "bugpoint ListReducer internal error: selected empty set.\n";
+      abort();
+
+    case NoFailure:
+      return false; // there is no failure with the full set of passes/funcs!
+    }
+
     unsigned MidTop = TheList.size();
     while (MidTop > 1) {
       unsigned Mid = MidTop / 2;
@@ -80,6 +97,8 @@
         }
       }
     }
+
+    return true; // there are some failure and we've narrowed them down
   }
 };
 


Index: llvm/tools/bugpoint/Miscompilation.cpp
diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.10 llvm/tools/bugpoint/Miscompilation.cpp:1.11
--- llvm/tools/bugpoint/Miscompilation.cpp:1.10	Thu Jul 24 13:17:43 2003
+++ llvm/tools/bugpoint/Miscompilation.cpp	Wed Jul 30 15:15:56 2003
@@ -268,12 +268,8 @@
     return false;  // Problem found
   }
 
-  // Figure out which transformations miscompile the input program.
-  unsigned OldSize = PassesToRun.size();
-  ReduceMiscompilingPasses(*this).reduceList(PassesToRun);
-
   // Make sure something was miscompiled...
-  if (PassesToRun.size() == OldSize) {
+  if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
     std::cerr << "*** Optimized program matches reference output!  No problem "
 	      << "detected...\nbugpoint can't help you with your problem!\n";
     return false;





More information about the llvm-commits mailing list