ByVal stack slot alignment should be at least as large as pointer ABI alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45995 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
index b8bc484..522ad73 100644
--- a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
+++ b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
@@ -15,6 +15,7 @@
 #include "llvm/CodeGen/CallingConvLower.h"
 #include "llvm/CodeGen/SelectionDAGNodes.h"
 #include "llvm/Target/MRegisterInfo.h"
+#include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
 using namespace llvm;
 
@@ -31,11 +32,12 @@
 void CCState::HandleStruct(unsigned ValNo, MVT::ValueType ValVT,
                            MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
                            unsigned ArgFlags) {
+  unsigned MinAlign = TM.getTargetData()->getPointerABIAlignment();
   unsigned Align  = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) >>
                           ISD::ParamFlags::ByValAlignOffs);
   unsigned Size   = (ArgFlags & ISD::ParamFlags::ByValSize) >>
       ISD::ParamFlags::ByValSizeOffs;
-  unsigned Offset = AllocateStack(Size, Align);
+  unsigned Offset = AllocateStack(Size, std::max(MinAlign, Align));
 
   addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
 }