From cf2112a0a014e834d720a86824828b47ccd1a48b Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 13 Sep 2006 18:55:37 +0000 Subject: [PATCH] Erase dead instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30298 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/PredicateSimplifier.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 42ae6adbb45..21dacf796ce 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -593,8 +593,8 @@ Value *PredicateSimplifier::resolve(Value *V, const PropertySet &KP) { void PredicateSimplifier::visitBasicBlock(DTNodeType *DTNode, PropertySet &KnownProperties) { BasicBlock *BB = DTNode->getBlock(); - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { - visitInstruction(I, DTNode, KnownProperties); + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) { + visitInstruction(I++, DTNode, KnownProperties); } } @@ -612,6 +612,7 @@ void PredicateSimplifier::visitInstruction(Instruction *I, modified = true; ++NumInstruction; I->replaceAllUsesWith(V); + I->eraseFromParent(); return; }