1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Make EmitProgressBitcode const and add a Module argument to runPasses. Use

that argument to simplify runPassesOn.

llvm-svn: 110291
This commit is contained in:
Rafael Espindola 2010-08-05 00:29:04 +00:00
parent fc6b043376
commit e580313f9e
5 changed files with 19 additions and 18 deletions

View File

@ -213,7 +213,7 @@ public:
/// "bugpoint-ID.bc".
///
void EmitProgressBitcode(const Module *M, const std::string &ID,
bool NoFlyer = false);
bool NoFlyer = false) const;
/// deleteInstructionFromProgram - This method clones the current Program and
/// deletes the specified instruction from the cloned module. It then runs a
@ -261,7 +261,8 @@ public:
/// or failed, unless Quiet is set. ExtraArgs specifies additional arguments
/// to pass to the child bugpoint instance.
///
bool runPasses(const std::vector<const PassInfo*> &PassesToRun,
bool runPasses(Module *Program,
const std::vector<const PassInfo*> &PassesToRun,
std::string &OutputFilename, bool DeleteOutput = false,
bool Quiet = false, unsigned NumExtraArgs = 0,
const char * const *ExtraArgs = NULL) const;
@ -289,7 +290,7 @@ private:
bool runPasses(const std::vector<const PassInfo*> &PassesToRun,
bool DeleteOutput = true) const {
std::string Filename;
return runPasses(PassesToRun, Filename, DeleteOutput);
return runPasses(Program, PassesToRun, Filename, DeleteOutput);
}
/// runAsChild - The actual "runPasses" guts that runs in a child process.

View File

@ -68,7 +68,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
outs() << "Checking to see if these passes crash: "
<< getPassesString(Prefix) << ": ";
std::string PfxOutput;
if (BD.runPasses(Prefix, PfxOutput))
if (BD.runPasses(BD.getProgram(), Prefix, PfxOutput))
return KeepPrefix;
PrefixOutput.set(PfxOutput);

View File

@ -62,7 +62,7 @@ bool BugDriver::runManyPasses(const std::vector<const PassInfo*> &AllPasses,
}
std::string Filename;
if(runPasses(PassesToRun, Filename, false)) {
if(runPasses(Program, PassesToRun, Filename, false)) {
outs() << "\n";
outs() << "Optimizer passes caused failure!\n\n";
debugOptimizerCrash();

View File

@ -67,7 +67,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< "' compiles correctly: ";
std::string BitcodeResult;
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
if (BD.runPasses(BD.getProgram(), Suffix, BitcodeResult, false/*delete*/,
true/*quiet*/)) {
errs() << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Suffix);
@ -104,7 +105,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// kept passes, we can update our bitcode file to include the result of the
// prefix passes, then discard the prefix passes.
//
if (BD.runPasses(Prefix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
if (BD.runPasses(BD.getProgram(), Prefix, BitcodeResult, false/*delete*/,
true/*quiet*/)) {
errs() << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Prefix);
@ -144,7 +146,8 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< getPassesString(Prefix) << "' passes: ";
OwningPtr<Module> OriginalInput(BD.swapProgramIn(PrefixOutput.take()));
if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
if (BD.runPasses(BD.getProgram(), Suffix, BitcodeResult, false/*delete*/,
true/*quiet*/)) {
errs() << " Error running this sequence of passes"
<< " on the input program!\n";
BD.setPassesToRun(Suffix);

View File

@ -66,7 +66,8 @@ bool BugDriver::writeProgramToFile(const std::string &Filename,
/// to a file named "bugpoint-ID.bc".
///
void BugDriver::EmitProgressBitcode(const Module *M,
const std::string &ID, bool NoFlyer) {
const std::string &ID,
bool NoFlyer) const {
// Output the input to the current pass to a bitcode file, emit a message
// telling the user how to reproduce it: opt -foo blah.bc
//
@ -125,7 +126,8 @@ cl::opt<bool> SilencePasses("silence-passes", cl::desc("Suppress output of runni
/// outs() a single line message indicating whether compilation was successful
/// or failed.
///
bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
bool BugDriver::runPasses(Module *Program,
const std::vector<const PassInfo*> &Passes,
std::string &OutputFilename, bool DeleteOutput,
bool Quiet, unsigned NumExtraArgs,
const char * const *ExtraArgs) const {
@ -239,24 +241,19 @@ Module *BugDriver::runPassesOn(Module *M,
const std::vector<const PassInfo*> &Passes,
bool AutoDebugCrashes, unsigned NumExtraArgs,
const char * const *ExtraArgs) {
Module *OldProgram = swapProgramIn(M);
std::string BitcodeResult;
if (runPasses(Passes, BitcodeResult, false/*delete*/, true/*quiet*/,
if (runPasses(M, Passes, BitcodeResult, false/*delete*/, true/*quiet*/,
NumExtraArgs, ExtraArgs)) {
if (AutoDebugCrashes) {
errs() << " Error running this sequence of passes"
<< " on the input program!\n";
delete OldProgram;
EmitProgressBitcode(Program, "pass-error", false);
delete swapProgramIn(M);
EmitProgressBitcode(M, "pass-error", false);
exit(debugOptimizerCrash());
}
swapProgramIn(OldProgram);
return 0;
}
// Restore the current program.
swapProgramIn(OldProgram);
Module *Ret = ParseInputFile(BitcodeResult, Context);
if (Ret == 0) {
errs() << getToolName() << ": Error reading bitcode file '"