diff options
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 5e2a2755fb..f7a68e48f8 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -310,15 +310,16 @@ bool ADCE::doADCE() { // should be identical to the incoming values for LastDead. // for (BasicBlock::iterator II = NextAlive->begin(); - PHINode *PN = dyn_cast<PHINode>(II); ++II) { - // Get the incoming value for LastDead... - int OldIdx = PN->getBasicBlockIndex(LastDead); - assert(OldIdx != -1 && "LastDead is not a pred of NextAlive!"); - Value *InVal = PN->getIncomingValue(OldIdx); - - // Add an incoming value for BB now... - PN->addIncoming(InVal, BB); - } + PHINode *PN = dyn_cast<PHINode>(II); ++II) + if (LiveSet.count(PN)) { // Only modify live phi nodes + // Get the incoming value for LastDead... + int OldIdx = PN->getBasicBlockIndex(LastDead); + assert(OldIdx != -1 &&"LastDead is not a pred of NextAlive!"); + Value *InVal = PN->getIncomingValue(OldIdx); + + // Add an incoming value for BB now... + PN->addIncoming(InVal, BB); + } } } |