diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-05 21:45:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-05 21:45:35 +0000 |
commit | fcb6ec0c7e37c2d15ddb04878f05cbd69d1da036 (patch) | |
tree | e9234e78c607dc7005b1f071a9cf0a80642515dd /tools/bugpoint/ExtractFunction.cpp | |
parent | 3323f2abbdfd2978f05d5260c63504c2325e76f0 (diff) |
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
Diffstat (limited to 'tools/bugpoint/ExtractFunction.cpp')
-rw-r--r-- | tools/bugpoint/ExtractFunction.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 2d7747af77..38e25864e4 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -37,9 +37,6 @@ namespace { cl::opt<bool, true> NoSCFG("disable-simplifycfg", cl::location(DisableSimplifyCFG), 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 @@ -89,29 +86,42 @@ Module *BugDriver::deleteInstructionFromProgram(Instruction *I, 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 /// a series of cleanups intended to get rid of extra cruft on the module /// before handing it to the user... /// -void BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) const { - // 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; - +Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) { // Make all functions external, so GlobalDCE doesn't delete them... for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) I->setLinkage(GlobalValue::ExternalLinkage); - PassManager CleanupPasses; - // Make sure that the appropriate target data is always used... - CleanupPasses.add(new TargetData("bugpoint", M)); - CleanupPasses.add(createFunctionResolvingPass()); - CleanupPasses.add(createGlobalDCEPass()); - CleanupPasses.add(createDeadTypeEliminationPass()); - CleanupPasses.add(createDeadArgEliminationPass(MayModifySemantics)); - CleanupPasses.add(createVerifierPass()); - CleanupPasses.run(*M); + std::vector<const PassInfo*> CleanupPasses; + CleanupPasses.push_back(getPI(createFunctionResolvingPass())); + CleanupPasses.push_back(getPI(createGlobalDCEPass())); + CleanupPasses.push_back(getPI(createDeadTypeEliminationPass())); + CleanupPasses.push_back(getPI(createDeadArgHackingPass())); + + std::swap(Program, M); + std::string Filename; + 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; } |