summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-08 21:36:34 +0000
committerChris Lattner <sabre@nondot.org>2002-10-08 21:36:34 +0000
commitdee430d26e14a3d7c8d86688d49ac8b116aa044f (patch)
tree916ba8a09761fe1fd92113e7e51b8c2e735a2b24
parentbb190ac8dafdcc5e604da3695987d69ee8632195 (diff)
downloadexternal_llvm-dee430d26e14a3d7c8d86688d49ac8b116aa044f.zip
external_llvm-dee430d26e14a3d7c8d86688d49ac8b116aa044f.tar.gz
external_llvm-dee430d26e14a3d7c8d86688d49ac8b116aa044f.tar.bz2
Changes to support PHINode::removeIncoming changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4080 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp4
-rw-r--r--lib/VMCore/BasicBlock.cpp13
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index c276450..f03253f 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -392,7 +392,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
BasicBlock *BB = OldPN->getIncomingBlock(0);
Value *OldVal = OldPN->getIncomingValue(0);
ValueHandle OldValHandle(VMC, OldVal);
- OldPN->removeIncomingValue(BB);
+ OldPN->removeIncomingValue(BB, false);
Value *V = ConvertExpressionToType(OldVal, Ty, VMC);
NewPN->addIncoming(V, BB);
}
@@ -1097,7 +1097,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
while (OldPN->getNumOperands()) {
BasicBlock *BB = OldPN->getIncomingBlock(0);
Value *OldVal = OldPN->getIncomingValue(0);
- OldPN->removeIncomingValue(BB);
+ OldPN->removeIncomingValue(BB, false);
Value *V = ConvertExpressionToType(OldVal, NewTy, VMC);
NewPN->addIncoming(V, BB);
}
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 2f1072d..667346c 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -183,16 +183,15 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) {
// Yup, loop through and nuke the PHI nodes
while (PHINode *PN = dyn_cast<PHINode>(&front())) {
PN->removeIncomingValue(Pred); // Remove the predecessor first...
-
- assert(PN->getNumIncomingValues() == max_idx-1 &&
- "PHI node shouldn't have this many values!!!");
// If the PHI _HAD_ two uses, replace PHI node with its now *single* value
- if (max_idx == 2)
+ if (max_idx == 2) {
PN->replaceAllUsesWith(PN->getOperand(0));
- else // Otherwise there are no incoming values/edges, replace with dummy
- PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
- getInstList().pop_front(); // Remove the PHI node
+ getInstList().pop_front(); // Remove the PHI node
+ }
+
+ // If the PHI node already only had one entry, it got deleted by
+ // removeIncomingValue.
}
} else {
// Okay, now we know that we need to remove predecessor #pred_idx from all