Fix the "horribly N^2'd" problem when deleting individual instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11617 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-02-18 23:59:11 +00:00
parent eb373aaa33
commit f66d9069cf

View File

@ -344,34 +344,45 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
// still triggers failure, keep deleting until we cannot trigger failure
// anymore.
//
unsigned InstructionsToSkipBeforeDeleting = 0;
TryAgain:
// Loop over all of the (non-terminator) instructions remaining in the
// function, attempting to delete them.
unsigned CurInstructionNum = 0;
for (Module::const_iterator FI = BD.getProgram()->begin(),
E = BD.getProgram()->end(); FI != E; ++FI)
if (!FI->isExternal()) {
if (!FI->isExternal())
for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E;
++BI)
for (BasicBlock::const_iterator I = BI->begin(), E = --BI->end();
I != E; ++I) {
Module *M = BD.deleteInstructionFromProgram(I, Simplification);
// Find out if the pass still crashes on this pass...
std::cout << "Checking instruction '" << I->getName() << "': ";
if (TestFn(BD, M)) {
// Yup, it does, we delete the old module, and continue trying to
// reduce the testcase...
BD.setNewProgram(M);
AnyReduction = true;
goto TryAgain; // I wish I had a multi-level break here!
I != E; ++I, ++CurInstructionNum)
if (InstructionsToSkipBeforeDeleting) {
--InstructionsToSkipBeforeDeleting;
} else {
std::cout << "Checking instruction '" << I->getName() << "': ";
Module *M = BD.deleteInstructionFromProgram(I, Simplification);
// Find out if the pass still crashes on this pass...
if (TestFn(BD, M)) {
// Yup, it does, we delete the old module, and continue trying
// to reduce the testcase...
BD.setNewProgram(M);
AnyReduction = true;
InstructionsToSkipBeforeDeleting = CurInstructionNum;
goto TryAgain; // I wish I had a multi-level break here!
}
// This pass didn't crash without this instruction, try the next
// one.
delete M;
}
// This pass didn't crash without this instruction, try the next
// one.
delete M;
}
}
if (InstructionsToSkipBeforeDeleting) {
InstructionsToSkipBeforeDeleting = 0;
goto TryAgain;
}
} while (Simplification);
// Try to clean up the testcase by running funcresolve and globaldce...