summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index d9a297cdf1..f1f7a44222 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -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;