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

that argument to simplify runPassesOn.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110291 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2010-08-05 00:29:04 +00:00
parent 602902ab80
commit ca356afe09
5 changed files with 19 additions and 18 deletions

View File

@@ -213,7 +213,7 @@ public:
/// "bugpoint-ID.bc". /// "bugpoint-ID.bc".
/// ///
void EmitProgressBitcode(const Module *M, const std::string &ID, void EmitProgressBitcode(const Module *M, const std::string &ID,
bool NoFlyer = false); bool NoFlyer = false) const;
/// deleteInstructionFromProgram - This method clones the current Program and /// deleteInstructionFromProgram - This method clones the current Program and
/// deletes the specified instruction from the cloned module. It then runs a /// 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 /// or failed, unless Quiet is set. ExtraArgs specifies additional arguments
/// to pass to the child bugpoint instance. /// 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, std::string &OutputFilename, bool DeleteOutput = false,
bool Quiet = false, unsigned NumExtraArgs = 0, bool Quiet = false, unsigned NumExtraArgs = 0,
const char * const *ExtraArgs = NULL) const; const char * const *ExtraArgs = NULL) const;
@@ -289,7 +290,7 @@ private:
bool runPasses(const std::vector<const PassInfo*> &PassesToRun, bool runPasses(const std::vector<const PassInfo*> &PassesToRun,
bool DeleteOutput = true) const { bool DeleteOutput = true) const {
std::string Filename; 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. /// 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: " outs() << "Checking to see if these passes crash: "
<< getPassesString(Prefix) << ": "; << getPassesString(Prefix) << ": ";
std::string PfxOutput; std::string PfxOutput;
if (BD.runPasses(Prefix, PfxOutput)) if (BD.runPasses(BD.getProgram(), Prefix, PfxOutput))
return KeepPrefix; return KeepPrefix;
PrefixOutput.set(PfxOutput); PrefixOutput.set(PfxOutput);

View File

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

View File

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

View File

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