[llvm-commits] CVS: llvm/tools/bugpoint/CrashDebugger.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Feb 18 18:00:01 PST 2004


Changes in directory llvm/tools/bugpoint:

CrashDebugger.cpp updated: 1.31 -> 1.32

---
Log message:

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


---
Diffs of the changes:  (+29 -18)

Index: llvm/tools/bugpoint/CrashDebugger.cpp
diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.31 llvm/tools/bugpoint/CrashDebugger.cpp:1.32
--- llvm/tools/bugpoint/CrashDebugger.cpp:1.31	Wed Feb 18 17:26:28 2004
+++ llvm/tools/bugpoint/CrashDebugger.cpp	Wed Feb 18 17:59:11 2004
@@ -344,34 +344,45 @@
     // 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...





More information about the llvm-commits mailing list