From: Chris Lattner Date: Tue, 13 Apr 2004 19:28:20 +0000 (+0000) Subject: Constant propagation should remove the dead instructions X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4647b7cd6929990ff174f0dd7cbfda5ab40df850;p=oota-llvm.git Constant propagation should remove the dead instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12917 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index d9a297cdf1f..f1f7a442221 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;