diff options
author | Lang Hames <lhames@gmail.com> | 2013-01-31 20:23:43 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2013-01-31 20:23:43 +0000 |
commit | 2d95e43fd877f81f419485baed3bd559de55e4c4 (patch) | |
tree | 0aea61dd4d4a0ccbce7b4867827af6b1e63b3b40 /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 8b15d74434dfde5ea9227b985c2c934f62bf03a7 (diff) |
When lowering memcpys to loads and stores, make sure we don't promote alignments
past the natural stack alignment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174085 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index b672926e9d..57241227d9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/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) |