diff options
-rw-r--r-- | lib/Transforms/Scalar/SROA.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index c33ee8fb87..1b3e8f9baf 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -2228,7 +2228,10 @@ private: // alloca that should be re-examined after rewriting this instruction. if (AllocaInst *AI = dyn_cast<AllocaInst>(OtherPtr->stripInBoundsOffsets())) - Pass.Worklist.insert(AI); + // Don't revisit the alloca if both sides of the memory transfer are + // referring to the same alloca. + if (AI != &NewAI) + Pass.Worklist.insert(AI); if (EmitMemCpy) { Value *OurPtr @@ -3108,12 +3111,6 @@ bool SROA::promoteAllocas(Function &F) { if (PromotableAllocas.empty()) return false; - // Ensure that the list is unique. - std::sort(PromotableAllocas.begin(), PromotableAllocas.end()); - PromotableAllocas.erase(std::unique(PromotableAllocas.begin(), - PromotableAllocas.end()), - PromotableAllocas.end()); - NumPromoted += PromotableAllocas.size(); if (DT && !ForceSSAUpdater) { |