1 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-win32 | FileCheck %s
3 ; Verify that the var arg parameters which are passed in registers are stored
4 ; in home stack slots allocated by the caller and that AP is correctly
6 define void @average_va(i32 %count, ...) nounwind {
9 ; CHECK-DAG: movq %r9, 40(%rsp)
10 ; CHECK-DAG: movq %r8, 32(%rsp)
11 ; CHECK-DAG: movq %rdx, 24(%rsp)
12 ; CHECK: leaq 24(%rsp), %rax
14 %ap = alloca ptr, align 8 ; <ptr> [#uses=1]
15 call void @llvm.va_start(ptr %ap)
19 declare void @llvm.va_start(ptr) nounwind
20 declare void @llvm.va_copy(ptr, ptr) nounwind
24 ; CHECK: leaq 56(%rsp),
25 define ptr @f5(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, ...) nounwind {
27 %ap = alloca ptr, align 8
28 call void @llvm.va_start(ptr %ap)
34 ; CHECK: leaq 48(%rsp),
35 define ptr @f4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
37 %ap = alloca ptr, align 8
38 call void @llvm.va_start(ptr %ap)
44 ; CHECK: leaq 40(%rsp),
45 define ptr @f3(i64 %a0, i64 %a1, i64 %a2, ...) nounwind {
47 %ap = alloca ptr, align 8
48 call void @llvm.va_start(ptr %ap)
52 ; WinX86_64 uses char* for va_list. Verify that the correct amount of bytes
53 ; are copied using va_copy.
57 ; CHECK: leaq 32(%rsp), [[REG_copy1:%[a-z]+]]
58 ; CHECK: movq [[REG_copy1]], 8(%rsp)
59 ; CHECK: movq [[REG_copy1]], (%rsp)
62 define void @copy1(i64 %a0, ...) nounwind {
64 %ap = alloca ptr, align 8
65 %cp = alloca ptr, align 8
66 call void @llvm.va_start(ptr %ap)
67 call void @llvm.va_copy(ptr %cp, ptr %ap)
73 ; CHECK: leaq 56(%rsp), [[REG_copy4:%[a-z]+]]
74 ; CHECK: movq [[REG_copy4]], 8(%rsp)
75 ; CHECK: movq [[REG_copy4]], (%rsp)
78 define void @copy4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
80 %ap = alloca ptr, align 8
81 %cp = alloca ptr, align 8
82 call void @llvm.va_start(ptr %ap)
83 call void @llvm.va_copy(ptr %cp, ptr %ap)
89 ; va_start (optimized away as overwritten by va_arg)
91 ; CHECK: leaq 52(%rsp), [[REG_arg4_2:%[a-z]+]]
92 ; CHECK: movq [[REG_arg4_2]], (%rsp)
93 ; CHECK: movl 48(%rsp), %eax
96 define i32 @arg4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
98 %ap = alloca ptr, align 8
99 call void @llvm.va_start(ptr %ap)
100 %tmp = va_arg ptr %ap, i32
104 define void @sret_arg(ptr sret(i32) %agg.result, ptr nocapture readnone %format, ...) {
107 call void @llvm.va_start(ptr %ap)
108 %tmp = va_arg ptr %ap, i32
109 store i32 %tmp, ptr %agg.result
112 ; CHECK-LABEL: sret_arg:
114 ; CHECK: movq %rcx, %rax
115 ; CHECK-DAG: movq %r9, 40(%rsp)
116 ; CHECK-DAG: movq %r8, 32(%rsp)
117 ; CHECK-DAG: leaq 36(%rsp), %[[sret:[^ ]*]]
118 ; CHECK-DAG: movl %r8d, (%rax)
119 ; CHECK-DAG: movq %[[sret]], (%rsp)