From e41d957028ddf5ff6fdd96c99f6a7fd9afa2358b Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 6 Aug 2014 17:57:23 +0000 Subject: Round up the size of byval arguments to MinAlign Otherwise we can end up with an argument frame size that is not a multiple of stack slot size, which is very awkward. This fixes PR20547, which was a bug in x86_64 Sys V vararg handling. However, it's much easier to test this with x86 callee-cleanup functions, which previously ended in "retl $6" instead of "retl $8". This does affect behavior of all backends, but it presumably fixes the same bug in all of them. llvm-svn: 214980 --- llvm/lib/CodeGen/CallingConvLower.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/CodeGen/CallingConvLower.cpp') diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp index 50fc6a179b6..cfcc9eae14e 100644 --- a/llvm/lib/CodeGen/CallingConvLower.cpp +++ b/llvm/lib/CodeGen/CallingConvLower.cpp @@ -52,6 +52,7 @@ void CCState::HandleByVal(unsigned ValNo, MVT ValVT, Align = MinAlign; MF.getFrameInfo()->ensureMaxAlignment(Align); TM.getSubtargetImpl()->getTargetLowering()->HandleByVal(this, Size, Align); + Size = unsigned(RoundUpToAlignment(Size, MinAlign)); unsigned Offset = AllocateStack(Size, Align); addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); } -- cgit v1.2.3