Most of bugpoint now only needs to know the pass names.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 8 Aug 2010 03:55:08 +0000 (03:55 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 8 Aug 2010 03:55:08 +0000 (03:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110534 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.cpp
tools/bugpoint/BugDriver.h
tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/ExtractFunction.cpp
tools/bugpoint/FindBugs.cpp
tools/bugpoint/Miscompilation.cpp
tools/bugpoint/OptimizerDriver.cpp
tools/bugpoint/bugpoint.cpp

index 7a3339cc9582db0d810c3dc98c4fb442f562ca0c..6966671f9cb2331814b1d3077fb4127ef50bbd1b 100644 (file)
@@ -56,12 +56,12 @@ void BugDriver::setNewProgram(Module *M) {
 /// getPassesString - Turn a list of passes into a string which indicates the
 /// command line options that must be passed to add the passes.
 ///
-std::string llvm::getPassesString(const std::vector<const PassInfo*> &Passes) {
+std::string llvm::getPassesString(const std::vector<std::string> &Passes) {
   std::string Result;
   for (unsigned i = 0, e = Passes.size(); i != e; ++i) {
     if (i) Result += " ";
     Result += "-";
-    Result += Passes[i]->getPassArgument();
+    Result += Passes[i];
   }
   return Result;
 }
index 6312ffaeb13ad0429366e2ac5af1e88de8650ebb..dbb7a3dd8f3a19fe70b6d2b09fe4e5892b7d0f5f 100644 (file)
@@ -47,7 +47,7 @@ class BugDriver {
   const char *ToolName;            // argv[0] of bugpoint
   std::string ReferenceOutputFile; // Name of `good' output file
   Module *Program;             // The raw program, linked together
-  std::vector<const PassInfo*> PassesToRun;
+  std::vector<std::string> PassesToRun;
   AbstractInterpreter *Interpreter;   // How to run the program
   AbstractInterpreter *SafeInterpreter;  // To generate reference output, etc.
   GCC *gcc;
@@ -74,12 +74,11 @@ public:
   // command line arguments into instance variables of BugDriver.
   //
   bool addSources(const std::vector<std::string> &FileNames);
-  template<class It>
-  void addPasses(It I, It E) { PassesToRun.insert(PassesToRun.end(), I, E); }
-  void setPassesToRun(const std::vector<const PassInfo*> &PTR) {
+  void addPass(std::string p) { PassesToRun.push_back(p); }
+  void setPassesToRun(const std::vector<std::string> &PTR) {
     PassesToRun = PTR;
   }
-  const std::vector<const PassInfo*> &getPassesToRun() const {
+  const std::vector<std::string> &getPassesToRun() const {
     return PassesToRun;
   }
 
@@ -243,7 +242,7 @@ public:
   /// failure.  If AutoDebugCrashes is set to true, then bugpoint will
   /// automatically attempt to track down a crashing pass if one exists, and
   /// this method will never return null.
-  Module *runPassesOn(Module *M, const std::vector<const PassInfo*> &Passes,
+  Module *runPassesOn(Module *M, const std::vector<std::string> &Passes,
                       bool AutoDebugCrashes = false, unsigned NumExtraArgs = 0,
                       const char * const *ExtraArgs = NULL);
 
@@ -257,7 +256,7 @@ public:
   /// to pass to the child bugpoint instance.
   ///
   bool runPasses(Module *Program,
-                 const std::vector<const PassInfo*> &PassesToRun,
+                 const std::vector<std::string> &PassesToRun,
                  std::string &OutputFilename, bool DeleteOutput = false,
                  bool Quiet = false, unsigned NumExtraArgs = 0,
                  const char * const *ExtraArgs = NULL) const;
@@ -269,7 +268,7 @@ public:
   /// If the passes did not compile correctly, output the command required to 
   /// recreate the failure. This returns true if a compiler error is found.
   ///
-  bool runManyPasses(const std::vector<const PassInfo*> &AllPasses,
+  bool runManyPasses(const std::vector<std::string> &AllPasses,
                      std::string &ErrMsg);
 
   /// writeProgramToFile - This writes the current "Program" to the named
@@ -283,7 +282,7 @@ private:
   /// input (true = crashed).
   ///
   bool runPasses(Module *M,
-                 const std::vector<const PassInfo*> &PassesToRun,
+                 const std::vector<std::string> &PassesToRun,
                  bool DeleteOutput = true) const {
     std::string Filename;
     return runPasses(M, PassesToRun, Filename, DeleteOutput);
@@ -305,7 +304,7 @@ Module *ParseInputFile(const std::string &InputFilename,
 /// getPassesString - Turn a list of passes into a string which indicates the
 /// command line options that must be passed to add the passes.
 ///
-std::string getPassesString(const std::vector<const PassInfo*> &Passes);
+std::string getPassesString(const std::vector<std::string> &Passes);
 
 /// PrintFunctionList - prints out list of problematic functions
 ///
index f96554b6f82541f5ffe999c1cb6a70fbb5cba1f7..2f73d9a58c3cd4391f793c4fd6df384efa4ae49d 100644 (file)
@@ -43,7 +43,7 @@ namespace {
 }
 
 namespace llvm {
-  class ReducePassList : public ListReducer<const PassInfo*> {
+  class ReducePassList : public ListReducer<std::string> {
     BugDriver &BD;
   public:
     ReducePassList(BugDriver &bd) : BD(bd) {}
@@ -52,15 +52,15 @@ namespace llvm {
     // running the "Kept" passes fail when run on the output of the "removed"
     // passes.  If we return true, we update the current module of bugpoint.
     //
-    virtual TestResult doTest(std::vector<const PassInfo*> &Removed,
-                              std::vector<const PassInfo*> &Kept,
+    virtual TestResult doTest(std::vector<std::string> &Removed,
+                              std::vector<std::string> &Kept,
                               std::string &Error);
   };
 }
 
 ReducePassList::TestResult
-ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
-                       std::vector<const PassInfo*> &Suffix,
+ReducePassList::doTest(std::vector<std::string> &Prefix,
+                       std::vector<std::string> &Suffix,
                        std::string &Error) {
   sys::Path PrefixOutput;
   Module *OrigProgram = 0;
index bbdc728890db566e84d0d10d2747fbfe9bc9537b..4e63e1698eb44a661983696cbe9dce62edd30067 100644 (file)
@@ -99,13 +99,6 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
   return Result;
 }
 
-static const PassInfo *getPI(Pass *P) {
-  const void *ID = P->getPassID();
-  const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
-  delete P;
-  return PI;
-}
-
 /// performFinalCleanups - This method clones the current Program and performs
 /// a series of cleanups intended to get rid of extra cruft on the module
 /// before handing it to the user.
@@ -115,15 +108,15 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
     I->setLinkage(GlobalValue::ExternalLinkage);
 
-  std::vector<const PassInfo*> CleanupPasses;
-  CleanupPasses.push_back(getPI(createGlobalDCEPass()));
+  std::vector<std::string> CleanupPasses;
+  CleanupPasses.push_back("globaldce");
 
   if (MayModifySemantics)
-    CleanupPasses.push_back(getPI(createDeadArgHackingPass()));
+    CleanupPasses.push_back("deadarghaX0r");
   else
-    CleanupPasses.push_back(getPI(createDeadArgEliminationPass()));
+    CleanupPasses.push_back("deadargelim");
 
-  CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
+  CleanupPasses.push_back("deadtypeelim");
 
   Module *New = runPassesOn(M, CleanupPasses);
   if (New == 0) {
@@ -139,8 +132,8 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
 /// function.  This returns null if there are no extractable loops in the
 /// program or if the loop extractor crashes.
 Module *BugDriver::ExtractLoop(Module *M) {
-  std::vector<const PassInfo*> LoopExtractPasses;
-  LoopExtractPasses.push_back(getPI(createSingleLoopExtractorPass()));
+  std::vector<std::string> LoopExtractPasses;
+  LoopExtractPasses.push_back("loop-extract-single");
 
   Module *NewM = runPassesOn(M, LoopExtractPasses);
   if (NewM == 0) {
@@ -354,8 +347,8 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
   std::string uniqueFN = "--extract-blocks-file=" + uniqueFilename.str();
   const char *ExtraArg = uniqueFN.c_str();
 
-  std::vector<const PassInfo*> PI;
-  PI.push_back(getPI(createBlockExtractorPass()));
+  std::vector<std::string> PI;
+  PI.push_back("extract-blocks");
   Module *Ret = runPassesOn(M, PI, false, 1, &ExtraArg);
 
   uniqueFilename.eraseFromDisk(); // Free disk space
index d4597dc1041cc13b2a73089a911905e70363c0db..a291f9fb0f99b6e9d78f6b2cef8afc1c902a4d6c 100644 (file)
@@ -29,7 +29,7 @@ using namespace llvm;
 /// If the passes did not compile correctly, output the command required to 
 /// recreate the failure. This returns true if a compiler error is found.
 ///
-bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses,
+bool BugDriver::runManyPasses(const std::vector<std::string> &AllPasses,
                               std::string &ErrMsg) {
   setPassesToRun(AllPasses);
   outs() << "Starting bug finding procedure...\n\n";
@@ -58,7 +58,7 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses,
     //
     outs() << "Running selected passes on program to test for crash: ";
     for(int i = 0, e = PassesToRun.size(); i != e; i++) {
-      outs() << "-" << PassesToRun[i]->getPassArgument() << " ";
+      outs() << "-" << PassesToRun[i] << " ";
     }
     
     std::string Filename;
index 0ae883c4841827860fd5179b1e76064e1af26d66..3f2b6968718b8aee2586d0b348d6ddf2ecbeb01b 100644 (file)
@@ -43,13 +43,13 @@ namespace {
         cl::desc("Don't extract blocks when searching for miscompilations"),
         cl::init(false));
 
-  class ReduceMiscompilingPasses : public ListReducer<const PassInfo*> {
+  class ReduceMiscompilingPasses : public ListReducer<std::string> {
     BugDriver &BD;
   public:
     ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
 
-    virtual TestResult doTest(std::vector<const PassInfo*> &Prefix,
-                              std::vector<const PassInfo*> &Suffix,
+    virtual TestResult doTest(std::vector<std::string> &Prefix,
+                              std::vector<std::string> &Suffix,
                               std::string &Error);
   };
 }
@@ -58,8 +58,8 @@ namespace {
 /// group, see if they still break the program.
 ///
 ReduceMiscompilingPasses::TestResult
-ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
-                                 std::vector<const PassInfo*> &Suffix,
+ReduceMiscompilingPasses::doTest(std::vector<std::string> &Prefix,
+                                 std::vector<std::string> &Suffix,
                                  std::string &Error) {
   // First, run the program with just the Suffix passes.  If it is still broken
   // with JUST the kept passes, discard the prefix passes.
index 15a5bfa2aef994ce29e18092b23f06704f4ded2b..7abcece3a84453f448218688ea5d28346236c14c 100644 (file)
@@ -97,7 +97,7 @@ cl::opt<bool> SilencePasses("silence-passes", cl::desc("Suppress output of runni
 /// or failed.
 ///
 bool BugDriver::runPasses(Module *Program,
-                          const std::vector<const PassInfo*> &Passes,
+                          const std::vector<std::string> &Passes,
                           std::string &OutputFilename, bool DeleteOutput,
                           bool Quiet, unsigned NumExtraArgs,
                           const char * const *ExtraArgs) const {
@@ -159,9 +159,9 @@ bool BugDriver::runPasses(Module *Program,
     pass_args.push_back( std::string("-load"));
     pass_args.push_back( PluginLoader::getPlugin(i));
   }
-  for (std::vector<const PassInfo*>::const_iterator I = Passes.begin(),
+  for (std::vector<std::string>::const_iterator I = Passes.begin(),
        E = Passes.end(); I != E; ++I )
-    pass_args.push_back( std::string("-") + (*I)->getPassArgument() );
+    pass_args.push_back( std::string("-") + (*I) );
   for (std::vector<std::string>::const_iterator I = pass_args.begin(),
        E = pass_args.end(); I != E; ++I )
     Args.push_back(I->c_str());
@@ -222,7 +222,7 @@ bool BugDriver::runPasses(Module *Program,
 /// module, returning the transformed module on success, or a null pointer on
 /// failure.
 Module *BugDriver::runPassesOn(Module *M,
-                               const std::vector<const PassInfo*> &Passes,
+                               const std::vector<std::string> &Passes,
                                bool AutoDebugCrashes, unsigned NumExtraArgs,
                                const char * const *ExtraArgs) {
   std::string BitcodeResult;
index 17f3fc7479d1139253392f0ed04193c3bc419886..025beec0bd86b5081e25c66104f450ff278d78f3 100644 (file)
@@ -85,7 +85,7 @@ namespace {
     virtual void add(Pass *P) {
       const void *ID = P->getPassID();
       const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID);
-      D.addPasses(&PI, &PI + 1);
+      D.addPass(PI->getPassArgument());
     }
   };
 }
@@ -137,7 +137,13 @@ int main(int argc, char **argv) {
                             /*RunInliner=*/true,
                             /*VerifyEach=*/false);
 
-  D.addPasses(PassList.begin(), PassList.end());
+
+  for (std::vector<const PassInfo*>::iterator I = PassList.begin(),
+         E = PassList.end();
+       I != E; ++I) {
+    const PassInfo* PI = *I;
+    D.addPass(PI->getPassArgument());
+  }
 
   // Bugpoint has the ability of generating a plethora of core files, so to
   // avoid filling up the disk, we prevent it