Files
clang-p2996/llvm/test/CodeGen/X86/vaargs-win32.ll
Wang, Pengfei 9d7d34c769 [X86][MS] Fix the aligement mismatch of vector variable arguments on Win32
The alignment of vector variable arguments in callee side is 4, which is
aligned with MSVC. But the caller aligns them to the size of vector
arguments. It results in run fails. This patch fixes this problem by
trimming it to 4 bytes for variable arguments on Win32.

Fixed vector arguments are passed by pointer on Win32. So they don't have
the problem.

I don't find a doc in MSDN for this calling conversion, so I did several
experiments here: https://godbolt.org/z/n1zn1Gx1z

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D108887
2021-09-08 09:26:44 +08:00

37 lines
1.2 KiB
LLVM

; RUN: llc -mcpu=generic -mtriple=i686-pc-windows-msvc -mattr=+sse < %s | FileCheck %s --check-prefix=MSVC
; RUN: llc -mcpu=generic -mtriple=i686-pc-mingw32 -mattr=+sse < %s | FileCheck %s --check-prefix=MINGW
@a = external dso_local global <4 x float>, align 16
define dso_local void @testPastArguments() nounwind {
; MSVC-LABEL: testPastArguments:
; MSVC: # %bb.0: # %entry
; MSVC-NEXT: subl $20, %esp
; MSVC-NEXT: movaps _a, %xmm0
; MSVC-NEXT: movups %xmm0, 4(%esp)
; MSVC-NEXT: movl $1, (%esp)
; MSVC-NEXT: calll _testm128
; MSVC-NEXT: addl $20, %esp
; MSVC-NEXT: retl
;
; MINGW-LABEL: testPastArguments:
; MINGW: # %bb.0: # %entry
; MINGW-NEXT: pushl %ebp
; MINGW-NEXT: movl %esp, %ebp
; MINGW-NEXT: andl $-16, %esp
; MINGW-NEXT: subl $48, %esp
; MINGW-NEXT: movaps _a, %xmm0
; MINGW-NEXT: movaps %xmm0, 16(%esp)
; MINGW-NEXT: movl $1, (%esp)
; MINGW-NEXT: calll _testm128
; MINGW-NEXT: movl %ebp, %esp
; MINGW-NEXT: popl %ebp
; MINGW-NEXT: retl
entry:
%0 = load <4 x float>, <4 x float>* @a, align 16
%call = tail call i32 (i32, ...) @testm128(i32 1, <4 x float> inreg %0)
ret void
}
declare i32 @testm128(i32, ...) nounwind