diff options
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 3ba56bbe53e..446e6758096 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -2370,6 +2370,12 @@ Instruction *InstCombiner::optimizeBitCastFromPhi(CastInst &CI, PHINode *PN) { llvm_unreachable("all uses should be handled"); } } + + // At this point the old phi has either no users, or is only used + // in other old phis. Replace with undef to break circles and remove + // the instruction. + replaceInstUsesWith(*OldPN, UndefValue::get(OldPN->getType())); + eraseInstFromFunction(*OldPN); } return RetVal; |