summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/ConstantProp.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-13 19:28:20 +0000
committerChris Lattner <sabre@nondot.org>2004-04-13 19:28:20 +0000
commitd0dc6d5295c761195f428dcb631577ee0e006a62 (patch)
treeb80efcee65c3619fc49d2b75405fe3b98aff151a /llvm/lib/Transforms/Scalar/ConstantProp.cpp
parente3debac3cd3c53038bc2b03648974bfd9d17b45e (diff)
downloadbcm5719-llvm-d0dc6d5295c761195f428dcb631577ee0e006a62.tar.gz
bcm5719-llvm-d0dc6d5295c761195f428dcb631577ee0e006a62.zip
Constant propagation should remove the dead instructions
llvm-svn: 12917
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ConstantProp.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/ConstantProp.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstantProp.cpp b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
index d9a297cdf1f..f1f7a442221 100644
--- a/llvm/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud