diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index ac893629fb5..725ba599bd9 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -26,6 +26,9 @@ namespace { cl::opt NoSCFG("disable-simplifycfg", cl::desc("Do not use the -simplifycfg pass to reduce testcases")); + cl::opt + NoFinalCleanup("disable-final-cleanup", + cl::desc("Disable the final cleanup phase of narrowing")); } /// deleteInstructionFromProgram - This method clones the current Program and @@ -79,10 +82,17 @@ Module *BugDriver::deleteInstructionFromProgram(Instruction *I, Module *BugDriver::performFinalCleanups() const { Module *M = CloneModule(Program); + // 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 M; + // 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; CleanupPasses.add(createFunctionResolvingPass()); CleanupPasses.add(createGlobalDCEPass());