don't revisit instructions off the beginning of the block.
authorChris Lattner <sabre@nondot.org>
Fri, 28 Nov 2008 22:50:08 +0000 (22:50 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 28 Nov 2008 22:50:08 +0000 (22:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60221 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/DeadStoreElimination.cpp

index b48bbeae66b2e3ddfb5f2186d9e3ad6e2820176b..e6a05b7e90b8b5e8f0a44d128de66095432c6779 100644 (file)
@@ -132,7 +132,8 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
       
       // If we deleted a store, reinvestigate this instruction.
       if (deletedStore) {
-        --BBI;
+        if (!isa<TerminatorInst>(BB.begin()))
+          --BBI;
         continue;
       }
     }
@@ -160,7 +161,8 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
              DT.dominates(dep, L))) {
           
           DeleteDeadInstruction(S);
-          --BBI;
+          if (!isa<TerminatorInst>(BB.begin()))
+            --BBI;
           NumFastStores++;
           MadeChange = true;
         } else