summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-08-08 03:55:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-08-08 03:55:08 +0000
commit8261dfed05e32302469ef707cc881fed2c31f85f (patch)
treebb97bbb81559b343d821cb49182073a7c245d4a4 /tools
parenta1cba686af266b361db6f705042e029e671742db (diff)
downloadllvm-8261dfed05e32302469ef707cc881fed2c31f85f.tar.gz
llvm-8261dfed05e32302469ef707cc881fed2c31f85f.tar.bz2
llvm-8261dfed05e32302469ef707cc881fed2c31f85f.tar.xz
Most of bugpoint now only needs to know the pass names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/BugDriver.cpp4
-rw-r--r--tools/bugpoint/BugDriver.h19
-rw-r--r--tools/bugpoint/CrashDebugger.cpp10
-rw-r--r--tools/bugpoint/ExtractFunction.cpp25
-rw-r--r--tools/bugpoint/FindBugs.cpp4
-rw-r--r--tools/bugpoint/Miscompilation.cpp10
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp8
-rw-r--r--tools/bugpoint/bugpoint.cpp10
8 files changed, 44 insertions, 46 deletions
diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp
index 7a3339cc95..6966671f9c 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<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;
}
diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h
index 6312ffaeb1..dbb7a3dd8f 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<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
///
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index f96554b6f8..2f73d9a58c 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -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;
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index bbdc728890..4e63e1698e 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<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
diff --git a/tools/bugpoint/FindBugs.cpp b/tools/bugpoint/FindBugs.cpp
index d4597dc104..a291f9fb0f 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<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;
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 0ae883c484..3f2b696871 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<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.
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index 15a5bfa2ae..7abcece3a8 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -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;
diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp
index 17f3fc7479..025beec0bd 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<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