diff options
author | Dale Johannesen <dalej@apple.com> | 2009-03-05 00:39:02 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2009-03-05 00:39:02 +0000 |
commit | a0a6637b2513935153e1d09f2a55bc14c85ba182 (patch) | |
tree | c0664b332456453362ba60083945c90b492e5af7 | |
parent | 85435046acda8890623249b30741d0ae544ad596 (diff) | |
download | llvm-a0a6637b2513935153e1d09f2a55bc14c85ba182.tar.gz llvm-a0a6637b2513935153e1d09f2a55bc14c85ba182.tar.bz2 llvm-a0a6637b2513935153e1d09f2a55bc14c85ba182.tar.xz |
Fix another case where a dbg.declare meant something
had 2 uses instead of 1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66112 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 66ac48181e..1679b9f4bc 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7502,8 +7502,10 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, // If the allocation has multiple uses, only promote it if we are strictly // increasing the alignment of the resultant allocation. If we keep it the - // same, we open the door to infinite loops of various kinds. - if (!AI.hasOneUse() && CastElTyAlign == AllocElTyAlign) return 0; + // same, we open the door to infinite loops of various kinds. (A reference + // from a dbg.declare doesn't count as a use for this purpose.) + if (!AI.hasOneUse() && !hasOneUsePlusDeclare(&AI) && + CastElTyAlign == AllocElTyAlign) return 0; uint64_t AllocElTySize = TD->getTypePaddedSize(AllocElTy); uint64_t CastElTySize = TD->getTypePaddedSize(CastElTy); @@ -7551,10 +7553,15 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, InsertNewInstBefore(New, AI); New->takeName(&AI); - // If the allocation has multiple uses, insert a cast and change all things - // that used it to use the new cast. This will also hack on CI, but it will - // die soon. - if (!AI.hasOneUse()) { + // If the allocation has one real use plus a dbg.declare, just remove the + // declare. + if (DbgDeclareInst *DI = hasOneUsePlusDeclare(&AI)) { + EraseInstFromFunction(*DI); + } + // If the allocation has multiple real uses, insert a cast and change all + // things that used it to use the new cast. This will also hack on CI, but it + // will die soon. + else if (!AI.hasOneUse()) { AddUsesToWorkList(AI); // New is the allocation instruction, pointer typed. AI is the original // allocation instruction, also pointer typed. Thus, cast to use is BitCast. |