Fix previous patch
authorChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2004 07:27:48 +0000 (07:27 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 10 Apr 2004 07:27:48 +0000 (07:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12811 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ADCE.cpp

index 18c11c3adee12d82a41f3ebdb693b7767cbb9442..8adf630f91cd7d4ae1cbf1d0a8c629b17a835099 100644 (file)
@@ -145,15 +145,13 @@ bool ADCE::dropReferencesOfDeadInstructionsInLiveBlock(BasicBlock *BB) {
         //
         PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
 
-      } else {
-        if (isa<CallInst>(I))
-          ++NumCallRemoved;
-        else
-          ++NumInstRemoved;
-        
         // Delete the instruction...
-        BB->getInstList().erase(I++);
+        ++I;
+        BB->getInstList().erase(PN);
         Changed = true;
+        ++NumInstRemoved;
+      } else {
+        ++I;
       }
     } else {
       ++I;