mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-24 04:09:47 +00:00
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
This commit is contained in:
parent
a1cba686af
commit
8261dfed05
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user