diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-29 05:23:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-29 05:23:10 +0000 |
commit | bca26a4c6ba4b2ac99fef6aeaece4fd514993102 (patch) | |
tree | b2779f00c29a0bacb312f3a357cd5dd3cea47785 /lib/Transforms/Scalar/ConstantProp.cpp | |
parent | 1be1d79a1d3260652f7796c1c07d70d98c62b119 (diff) |
We need to make sure to remove PHI nodes in the successor that cannot be
executed when removing branch dest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/ConstantProp.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 9d70d842be..2df4f01a7e 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -129,6 +129,14 @@ inline static bool ConstantFoldTerminator(TerminatorInst *T) { // YES. Change to unconditional branch... ConstPoolBool *Cond = (ConstPoolBool*)BI->getOperand(2); Value *Destination = BI->getOperand(Cond->getValue() ? 0 : 1); + Value *OldDest = BI->getOperand(Cond->getValue() ? 1 : 0); + + //cerr << "Method: " << T->getParent()->getParent() << "\nRemoving branch from " << T->getParent() << "\n\nTo: " << OldDest << endl; + + // Let the basic block know that we are letting go of it. Based on this, + // it will adjust it's PHI nodes. + assert(T->getParent() && "Terminator not inserted in block!"); + OldDest->castBasicBlockAsserting()->removePredecessor(T->getParent()); BI->setOperand(0, Destination); // Set the unconditional destination BI->setOperand(1, 0); // Clear the conditional destination |