diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index 7a3339cc958..6966671f9cb 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -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 &Passes) { +std::string llvm::getPassesString(const std::vector &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; } diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index 6312ffaeb13..dbb7a3dd8f3 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -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 PassesToRun; + std::vector 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 &FileNames); - template - void addPasses(It I, It E) { PassesToRun.insert(PassesToRun.end(), I, E); } - void setPassesToRun(const std::vector &PTR) { + void addPass(std::string p) { PassesToRun.push_back(p); } + void setPassesToRun(const std::vector &PTR) { PassesToRun = PTR; } - const std::vector &getPassesToRun() const { + const std::vector &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 &Passes, + Module *runPassesOn(Module *M, const std::vector &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 &PassesToRun, + const std::vector &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 &AllPasses, + bool runManyPasses(const std::vector &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 &PassesToRun, + const std::vector &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 &Passes); +std::string getPassesString(const std::vector &Passes); /// PrintFunctionList - prints out list of problematic functions /// diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index f96554b6f82..2f73d9a58c3 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -43,7 +43,7 @@ namespace { } namespace llvm { - class ReducePassList : public ListReducer { + class ReducePassList : public ListReducer { 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 &Removed, - std::vector &Kept, + virtual TestResult doTest(std::vector &Removed, + std::vector &Kept, std::string &Error); }; } ReducePassList::TestResult -ReducePassList::doTest(std::vector &Prefix, - std::vector &Suffix, +ReducePassList::doTest(std::vector &Prefix, + std::vector &Suffix, std::string &Error) { sys::Path PrefixOutput; Module *OrigProgram = 0; diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index bbdc728890d..4e63e1698eb 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -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 CleanupPasses; - CleanupPasses.push_back(getPI(createGlobalDCEPass())); + std::vector 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 LoopExtractPasses; - LoopExtractPasses.push_back(getPI(createSingleLoopExtractorPass())); + std::vector 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 PI; - PI.push_back(getPI(createBlockExtractorPass())); + std::vector PI; + PI.push_back("extract-blocks"); Module *Ret = runPassesOn(M, PI, false, 1, &ExtraArg); uniqueFilename.eraseFromDisk(); // Free disk space diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp index d4597dc1041..a291f9fb0f9 100644 --- a/tools/bugpoint/FindBugs.cpp +++ b/tools/bugpoint/FindBugs.cpp @@ -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 &AllPasses, +bool BugDriver::runManyPasses(const std::vector &AllPasses, std::string &ErrMsg) { setPassesToRun(AllPasses); outs() << "Starting bug finding procedure...\n\n"; @@ -58,7 +58,7 @@ bool BugDriver::runManyPasses(const std::vector &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; diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 0ae883c4841..3f2b6968718 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -43,13 +43,13 @@ namespace { cl::desc("Don't extract blocks when searching for miscompilations"), cl::init(false)); - class ReduceMiscompilingPasses : public ListReducer { + class ReduceMiscompilingPasses : public ListReducer { BugDriver &BD; public: ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {} - virtual TestResult doTest(std::vector &Prefix, - std::vector &Suffix, + virtual TestResult doTest(std::vector &Prefix, + std::vector &Suffix, std::string &Error); }; } @@ -58,8 +58,8 @@ namespace { /// group, see if they still break the program. /// ReduceMiscompilingPasses::TestResult -ReduceMiscompilingPasses::doTest(std::vector &Prefix, - std::vector &Suffix, +ReduceMiscompilingPasses::doTest(std::vector &Prefix, + std::vector &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. diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 15a5bfa2aef..7abcece3a84 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -97,7 +97,7 @@ cl::opt SilencePasses("silence-passes", cl::desc("Suppress output of runni /// or failed. /// bool BugDriver::runPasses(Module *Program, - const std::vector &Passes, + const std::vector &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_iterator I = Passes.begin(), + for (std::vector::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::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 &Passes, + const std::vector &Passes, bool AutoDebugCrashes, unsigned NumExtraArgs, const char * const *ExtraArgs) { std::string BitcodeResult; diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 17f3fc7479d..025beec0bd8 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -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::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