Constant propagation should remove the dead instructions
authorChris Lattner <sabre@nondot.org>
Tue, 13 Apr 2004 19:28:20 +0000 (19:28 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Apr 2004 19:28:20 +0000 (19:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12917 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ConstantProp.cpp

index d9a297cdf1f4e3b6915a7393e1da17519aa7c99d..f1f7a4422211e32cf0950d48ac2beb045cccd677 100644 (file)
@@ -67,6 +67,10 @@ bool ConstantPropagation::runOnFunction(Function &F) {
         // Replace all of the uses of a variable with uses of the constant.
         I->replaceAllUsesWith(C);
 
+        // Remove the dead instruction.
+        WorkList.erase(I);
+        I->getParent()->getInstList().erase(I);
+
         // We made a change to the function...
         Changed = true;
         ++NumInstKilled;