Correctly update counters
authorChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2004 07:02:02 +0000 (07:02 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2004 07:02:02 +0000 (07:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12810 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ADCE.cpp

index afc24f95f11b0658aad8368d37ab2f449214c511..18c11c3adee12d82a41f3ebdb693b7767cbb9442 100644 (file)
@@ -144,13 +144,16 @@ bool ADCE::dropReferencesOfDeadInstructionsInLiveBlock(BasicBlock *BB) {
         // #arguments != #predecessors, so we remove them now.
         //
         PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
+
+      } else {
+        if (isa<CallInst>(I))
+          ++NumCallRemoved;
+        else
+          ++NumInstRemoved;
         
         // Delete the instruction...
-        I = BB->getInstList().erase(I);
+        BB->getInstList().erase(I++);
         Changed = true;
-        ++NumInstRemoved;
-      } else {
-        ++I;
       }
     } else {
       ++I;
@@ -497,8 +500,11 @@ bool ADCE::doADCE() {
       for (BasicBlock::iterator II = BI->begin(); II != --BI->end(); )
         if (!LiveSet.count(II)) {             // Is this instruction alive?
           // Nope... remove the instruction from it's basic block...
+          if (isa<CallInst>(II))
+            ++NumCallRemoved;
+          else
+            ++NumInstRemoved;
           II = BI->getInstList().erase(II);
-          ++NumInstRemoved;
           MadeChanges = true;
         } else {
           ++II;