diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-11-24 19:25:36 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-11-24 19:25:36 +0000 |
| commit | 53d6a078697a3345f485e4f5b496ab17fc93e8ba (patch) | |
| tree | 2f50781be4772040686b9f08ff5f2d58c7eeb45f /llvm/lib/Transforms/Scalar | |
| parent | 66835479d742e248c905e9dcd87b1d8e01b5aa0b (diff) | |
| download | bcm5719-llvm-53d6a078697a3345f485e4f5b496ab17fc93e8ba.tar.gz bcm5719-llvm-53d6a078697a3345f485e4f5b496ab17fc93e8ba.zip | |
Fix 3113: If we have a dead cyclic PHI, replace the whole thing
with an undef.
llvm-svn: 59972
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp index a04ccfea361..b8664b0d4a1 100644 --- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -206,7 +206,10 @@ void CodeGenPrepare::EliminateMostlyEmptyBlock(BasicBlock *BB) { if (DestBB->getSinglePredecessor()) { // If DestBB has single-entry PHI nodes, fold them. while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) { - PN->replaceAllUsesWith(PN->getIncomingValue(0)); + Value *NewVal = PN->getIncomingValue(0); + // Replace self referencing PHI with undef, it must be dead. + if (NewVal == PN) NewVal = UndefValue::get(PN->getType()); + PN->replaceAllUsesWith(NewVal); PN->eraseFromParent(); } @@ -569,6 +572,9 @@ static bool FindMaximalLegalAddressingMode(Value *Addr, const Type *AccessTy, if (Instruction *I = dyn_cast_or_null<Instruction>(AddrInst)) AddrModeInsts.push_back(I); + if (AddrInst && !AddrInst->hasOneUse()) + ; + else switch (Opcode) { case Instruction::PtrToInt: // PtrToInt is always a noop, as we know that the int type is pointer sized. |

