From eb30bb7d295af9cf16a84aab84c97028d66bf8df Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 15 Jan 2008 07:49:36 +0000 Subject: [PATCH] Oops. Forgot to commit this. llvm-svn: 46002 --- .../CodeGen/SelectionDAG/CallingConvLower.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/CallingConvLower.cpp b/llvm/lib/CodeGen/SelectionDAG/CallingConvLower.cpp index 522ad7399e2c..337c7fda9ab2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/CallingConvLower.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/CallingConvLower.cpp @@ -29,15 +29,22 @@ CCState::CCState(unsigned CC, bool isVarArg, const TargetMachine &tm, UsedRegs.resize(MRI.getNumRegs()); } -void CCState::HandleStruct(unsigned ValNo, MVT::ValueType ValVT, - MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo, - unsigned ArgFlags) { - unsigned MinAlign = TM.getTargetData()->getPointerABIAlignment(); +// HandleByVal - Allocate a stack slot large enough to pass an argument by +// value. The size and alignment information of the argument is encoded in its +// parameter attribute. +void CCState::HandleByVal(unsigned ValNo, MVT::ValueType ValVT, + MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo, + int MinSize, int MinAlign, + unsigned ArgFlags) { unsigned Align = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) >> ISD::ParamFlags::ByValAlignOffs); unsigned Size = (ArgFlags & ISD::ParamFlags::ByValSize) >> ISD::ParamFlags::ByValSizeOffs; - unsigned Offset = AllocateStack(Size, std::max(MinAlign, Align)); + if (MinSize > (int)Size) + Size = MinSize; + if (MinAlign > (int)Align) + Align = MinAlign; + unsigned Offset = AllocateStack(Size, Align); addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); }