forked from OSchip/llvm-project
Add code to ensure that no PHI nodes are left laying around with their
arguments dropped. This fixes bug: test/Regression/Transforms/ADCE/2002-07-17-PHIAssertion.ll llvm-svn: 3134
This commit is contained in:
parent
2511b6e296
commit
3be5d0b892
|
@ -284,9 +284,23 @@ bool ADCE::doADCE() {
|
||||||
// sweep over the program can safely delete dead instructions without
|
// sweep over the program can safely delete dead instructions without
|
||||||
// other dead instructions still refering to them.
|
// other dead instructions still refering to them.
|
||||||
//
|
//
|
||||||
for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I)
|
for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; )
|
||||||
if (!LiveSet.count(I)) // Is this instruction alive?
|
if (!LiveSet.count(I)) { // Is this instruction alive?
|
||||||
I->dropAllReferences(); // Nope, drop references...
|
I->dropAllReferences(); // Nope, drop references...
|
||||||
|
if (PHINode *PN = dyn_cast<PHINode>(&*I)) {
|
||||||
|
// We don't want to leave PHI nodes in the program that have
|
||||||
|
// #arguments != #predecessors, so we remove them now.
|
||||||
|
//
|
||||||
|
PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
|
||||||
|
|
||||||
|
// Delete the instruction...
|
||||||
|
I = BB->getInstList().erase(I);
|
||||||
|
} else {
|
||||||
|
++I;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++I;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue