summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2013-01-31 20:23:43 +0000
committerLang Hames <lhames@gmail.com>2013-01-31 20:23:43 +0000
commitdd47804394881b4af75fa62edd88c9d45570ab9f (patch)
tree56a0343cb9b6d4d59c3054356cf311cd610d3f0c /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent53f3f9f0cbc3688a9ed77b185b70c2ef608d4481 (diff)
downloadbcm5719-llvm-dd47804394881b4af75fa62edd88c9d45570ab9f.tar.gz
bcm5719-llvm-dd47804394881b4af75fa62edd88c9d45570ab9f.zip
When lowering memcpys to loads and stores, make sure we don't promote alignments
past the natural stack alignment. llvm-svn: 174085
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index b672926e9d3..57241227d9e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3561,6 +3561,15 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl,
if (DstAlignCanChange) {
Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext());
unsigned NewAlign = (unsigned) TLI.getDataLayout()->getABITypeAlignment(Ty);
+
+ // Don't promote to an alignment that would require dynamic stack
+ // realignment.
+ const TargetRegisterInfo *TRI = MF.getTarget().getRegisterInfo();
+ if (!TRI->needsStackRealignment(MF))
+ while (NewAlign > Align &&
+ TLI.getDataLayout()->exceedsNaturalStackAlignment(NewAlign))
+ NewAlign /= 2;
+
if (NewAlign > Align) {
// Give the stack frame object a larger alignment if needed.
if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign)
OpenPOWER on IntegriCloud