From: Duncan Sands Date: Wed, 17 Nov 2010 10:23:23 +0000 (+0000) Subject: Now that hasConstantValue has been made simpler, it may return the X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=23a19572b2839ee3a6a3520d60d62a465cec7d53;p=oota-llvm.git Now that hasConstantValue has been made simpler, it may return the phi node itself if it occurs in an unreachable basic block. Protect against this. Hopefully this will fix some more buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119493 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp index e5e7cd38576..0cdb4b1a1c9 100644 --- a/lib/Analysis/Lint.cpp +++ b/lib/Analysis/Lint.cpp @@ -583,7 +583,8 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk, } } else if (PHINode *PN = dyn_cast(V)) { if (Value *W = PN->hasConstantValue()) - return findValueImpl(W, OffsetOk, Visited); + if (W != V) + return findValueImpl(W, OffsetOk, Visited); } else if (CastInst *CI = dyn_cast(V)) { if (CI->isNoopCast(TD ? TD->getIntPtrType(V->getContext()) : Type::getInt64Ty(V->getContext()))) diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 8ad53736c99..955a0285b26 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -248,10 +248,11 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, // If all incoming values to the Phi are the same, we can replace the Phi // with that value. Value* PNV = 0; - if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue())) { - PN->replaceAllUsesWith(PNV); - PN->eraseFromParent(); - } + if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue())) + if (PNV != PN) { + PN->replaceAllUsesWith(PNV); + PN->eraseFromParent(); + } } } }