I hate it when bugpoint is all ready to give me a bytecode file, then crashes

in final cleanups.  Then you had to run the whole mess again with
-disable-final-cleanups.

This makes bugpoint run the cleanups in a protected environment so that if
they crash, bugpoint itself doesn't crash.  This makes things much happier,
implements a FIXME, and gets rid of YABPO (yet another bugpoint option).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-11-05 21:45:35 +00:00
parent 3323f2abbd
commit fcb6ec0c7e
4 changed files with 35 additions and 25 deletions

View File

@@ -120,7 +120,7 @@ private:
/// EmitProgressBytecode - This function is used to output the current Program /// EmitProgressBytecode - This function is used to output the current Program
/// to a file named "bugpoing-ID.bc". /// to a file named "bugpoint-ID.bc".
/// ///
void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false); void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false);
@@ -162,7 +162,7 @@ private:
/// the MayModifySemantics argument is true, then the cleanups is allowed to /// the MayModifySemantics argument is true, then the cleanups is allowed to
/// modify how the code behaves. /// modify how the code behaves.
/// ///
void performFinalCleanups(Module *M, bool MayModifySemantics = false) const; Module *performFinalCleanups(Module *M, bool MayModifySemantics = false);
/// initializeExecutionEnvironment - This method is used to set up the /// initializeExecutionEnvironment - This method is used to set up the
/// environment for executing LLVM programs. /// environment for executing LLVM programs.

View File

@@ -224,8 +224,8 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
} }
// Clean up the modules, removing extra cruft that we don't need anymore... // Clean up the modules, removing extra cruft that we don't need anymore...
BD.performFinalCleanups(SafeModule); SafeModule = BD.performFinalCleanups(SafeModule);
BD.performFinalCleanups(TestModule); TestModule = BD.performFinalCleanups(TestModule);
if (BD.writeProgramToFile(TestModuleBC, TestModule)) { if (BD.writeProgramToFile(TestModuleBC, TestModule)) {
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting."; std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";

View File

@@ -379,7 +379,7 @@ bool BugDriver::debugCrash() {
// Try to clean up the testcase by running funcresolve and globaldce... // Try to clean up the testcase by running funcresolve and globaldce...
std::cout << "\n*** Attempting to perform final cleanups: "; std::cout << "\n*** Attempting to perform final cleanups: ";
Module *M = CloneModule(Program); Module *M = CloneModule(Program);
performFinalCleanups(M, true); M = performFinalCleanups(M, true);
std::swap(Program, M); std::swap(Program, M);
// Find out if the pass still crashes on the cleaned up program... // Find out if the pass still crashes on the cleaned up program...

View File

@@ -37,9 +37,6 @@ namespace {
cl::opt<bool, true> cl::opt<bool, true>
NoSCFG("disable-simplifycfg", cl::location(DisableSimplifyCFG), NoSCFG("disable-simplifycfg", cl::location(DisableSimplifyCFG),
cl::desc("Do not use the -simplifycfg pass to reduce testcases")); cl::desc("Do not use the -simplifycfg pass to reduce testcases"));
cl::opt<bool>
NoFinalCleanup("disable-final-cleanup",
cl::desc("Disable the final cleanup phase of narrowing"));
} }
/// deleteInstructionFromProgram - This method clones the current Program and /// deleteInstructionFromProgram - This method clones the current Program and
@@ -89,29 +86,42 @@ Module *BugDriver::deleteInstructionFromProgram(Instruction *I,
return Result; return Result;
} }
static const PassInfo *getPI(Pass *P) {
const PassInfo *PI = P->getPassInfo();
delete P;
return PI;
}
/// performFinalCleanups - This method clones the current Program and performs /// performFinalCleanups - This method clones the current Program and performs
/// a series of cleanups intended to get rid of extra cruft on the module /// a series of cleanups intended to get rid of extra cruft on the module
/// before handing it to the user... /// before handing it to the user...
/// ///
void BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) const { Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
// Allow disabling these passes if they crash bugpoint.
//
// FIXME: This should eventually run these passes in a pass list to prevent
// them from being able to crash bugpoint at all!
//
if (NoFinalCleanup) return;
// Make all functions external, so GlobalDCE doesn't delete them... // Make all functions external, so GlobalDCE doesn't delete them...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
I->setLinkage(GlobalValue::ExternalLinkage); I->setLinkage(GlobalValue::ExternalLinkage);
PassManager CleanupPasses; std::vector<const PassInfo*> CleanupPasses;
// Make sure that the appropriate target data is always used... CleanupPasses.push_back(getPI(createFunctionResolvingPass()));
CleanupPasses.add(new TargetData("bugpoint", M)); CleanupPasses.push_back(getPI(createGlobalDCEPass()));
CleanupPasses.add(createFunctionResolvingPass()); CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
CleanupPasses.add(createGlobalDCEPass()); CleanupPasses.push_back(getPI(createDeadArgHackingPass()));
CleanupPasses.add(createDeadTypeEliminationPass());
CleanupPasses.add(createDeadArgEliminationPass(MayModifySemantics)); std::swap(Program, M);
CleanupPasses.add(createVerifierPass()); std::string Filename;
CleanupPasses.run(*M); bool Failed = runPasses(CleanupPasses, Filename);
std::swap(Program, M);
if (Failed) {
std::cerr << "Final cleanups failed. Sorry. :(\n";
} else {
delete M;
M = ParseInputFile(Filename);
if (M == 0) {
std::cerr << getToolName() << ": Error reading bytecode file '"
<< Filename << "'!\n";
exit(1);
}
}
return M;
} }