summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-09-26 10:59:22 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-09-26 10:59:22 +0000
commit208124f5a27255bd96b279847631136c711f4ada (patch)
tree4f85267e2a4822f93bba18870fefb18d0833c77e
parent3e4273dd0c1e6d2ae31945777e8af4ed1398f698 (diff)
downloadbcm5719-llvm-208124f5a27255bd96b279847631136c711f4ada.tar.gz
bcm5719-llvm-208124f5a27255bd96b279847631136c711f4ada.zip
Analogous fix to memset and memcpy rewriting. Don't have a test case
contrived for these yet, as I spotted them by inspection and the test cases are a bit more tricky to phrase. llvm-svn: 164691
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 67246a5a1cc..cf12cfca18e 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -2064,6 +2064,15 @@ private:
// pointer to the new alloca.
if (!isa<Constant>(II.getLength())) {
II.setDest(getAdjustedAllocaPtr(IRB, II.getRawDest()->getType()));
+
+ Type *CstTy = II.getAlignmentCst()->getType();
+ if (!NewAI.getAlignment())
+ II.setAlignment(ConstantInt::get(CstTy, 0));
+ else
+ II.setAlignment(
+ ConstantInt::get(CstTy, MinAlign(NewAI.getAlignment(),
+ BeginOffset - NewAllocaBeginOffset)));
+
deleteIfTriviallyDead(OldPtr);
return false;
}
@@ -2187,6 +2196,13 @@ private:
else
II.setSource(getAdjustedAllocaPtr(IRB, II.getRawSource()->getType()));
+ Type *CstTy = II.getAlignmentCst()->getType();
+ if (II.getAlignment() > 1)
+ II.setAlignment(ConstantInt::get(
+ CstTy, MinAlign(II.getAlignment(),
+ MinAlign(NewAI.getAlignment(),
+ BeginOffset - NewAllocaBeginOffset))));
+
DEBUG(dbgs() << " to: " << II << "\n");
deleteIfTriviallyDead(OldOp);
return false;
OpenPOWER on IntegriCloud