diff options
author | Duncan Sands <baldrick@free.fr> | 2010-11-17 10:23:23 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-11-17 10:23:23 +0000 |
commit | ec7a6ecb92cf4e6472b13fbff974affe74710b78 (patch) | |
tree | a1a712255d4b2a4e31bac678c83781ea029b4384 /llvm/lib | |
parent | 7c91bb855f26dacc0548dbac842e7755cc43ee82 (diff) | |
download | bcm5719-llvm-ec7a6ecb92cf4e6472b13fbff974affe74710b78.tar.gz bcm5719-llvm-ec7a6ecb92cf4e6472b13fbff974affe74710b78.zip |
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.
llvm-svn: 119493
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/Lint.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp index e5e7cd38576..0cdb4b1a1c9 100644 --- a/llvm/lib/Analysis/Lint.cpp +++ b/llvm/lib/Analysis/Lint.cpp @@ -583,7 +583,8 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk, } } else if (PHINode *PN = dyn_cast<PHINode>(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<CastInst>(V)) { if (CI->isNoopCast(TD ? TD->getIntPtrType(V->getContext()) : Type::getInt64Ty(V->getContext()))) diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index 8ad53736c99..955a0285b26 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/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(); + } } } } |