summaryrefslogtreecommitdiff
path: root/tools/bugpoint/CrashDebugger.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-18 23:59:11 +0000
committerChris Lattner <sabre@nondot.org>2004-02-18 23:59:11 +0000
commitf66d9069cff9ee8b3658b92d3a13d04d198ada91 (patch)
tree022c14da523809a2cf16939357bf960f85fc5f45 /tools/bugpoint/CrashDebugger.cpp
parenteb373aaa33e3f16d3da8720bfcde4bc72bd1b103 (diff)
downloadllvm-f66d9069cff9ee8b3658b92d3a13d04d198ada91.tar.gz
llvm-f66d9069cff9ee8b3658b92d3a13d04d198ada91.tar.bz2
llvm-f66d9069cff9ee8b3658b92d3a13d04d198ada91.tar.xz
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
Diffstat (limited to 'tools/bugpoint/CrashDebugger.cpp')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index d9d52dccc0..a0b695cc21 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -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...