Index: tools/bugpoint/BugDriver.h =================================================================== --- tools/bugpoint/BugDriver.h +++ tools/bugpoint/BugDriver.h @@ -200,7 +200,8 @@ /// This method clones the current Program and deletes the specified /// instruction from the cloned module. It then runs a series of cleanup /// passes (ADCE and SimplifyCFG) to eliminate any code which depends on the - /// value. The modified module is then returned. + /// value. The modified module is then returned. If deletion causes module + /// verification to fail, nullptr is returned. /// std::unique_ptr deleteInstructionFromProgram(const Instruction *I, unsigned Simp); Index: tools/bugpoint/CrashDebugger.cpp =================================================================== --- tools/bugpoint/CrashDebugger.cpp +++ tools/bugpoint/CrashDebugger.cpp @@ -451,7 +451,7 @@ std::unique_ptr New = BD.runPassesOn(M.get(), Passes); if (!New) { errs() << "verify failed!\n"; - exit(1); + return false; } M = std::move(New); @@ -558,7 +558,7 @@ std::unique_ptr New = BD.runPassesOn(M.get(), Passes); if (!New) { errs() << "verify failed!\n"; - exit(1); + return false; } M = std::move(New); @@ -650,7 +650,7 @@ std::unique_ptr New = BD.runPassesOn(M.get(), Passes); if (!New) { errs() << "verify failed!\n"; - exit(1); + return false; } M = std::move(New); @@ -1010,6 +1010,8 @@ outs() << "Checking instruction: " << *I; std::unique_ptr M = BD.deleteInstructionFromProgram(&*I, Simplification); + if (!M) // We couldn't delete this instruction. Keep trying. + continue; // Find out if the pass still crashes on this pass... if (TestFn(BD, M.get())) { Index: tools/bugpoint/ExtractFunction.cpp =================================================================== --- tools/bugpoint/ExtractFunction.cpp +++ tools/bugpoint/ExtractFunction.cpp @@ -121,7 +121,7 @@ std::unique_ptr New = runPassesOn(Clone.get(), Passes); if (!New) { errs() << "Instruction removal failed. Sorry. :( Please report a bug!\n"; - exit(1); + return nullptr; } return New; }