1 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-linux-gnu | 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 win64cc 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
21 declare void @llvm.va_end(ptr) nounwind
25 ; CHECK: leaq 56(%rsp),
26 define win64cc ptr @f5(i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, ...) nounwind {
28 %ap = alloca ptr, align 8
29 call void @llvm.va_start(ptr %ap)
35 ; CHECK: leaq 48(%rsp),
36 define win64cc ptr @f4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
38 %ap = alloca ptr, align 8
39 call void @llvm.va_start(ptr %ap)
45 ; CHECK: leaq 40(%rsp),
46 define win64cc ptr @f3(i64 %a0, i64 %a1, i64 %a2, ...) nounwind {
48 %ap = alloca ptr, align 8
49 call void @llvm.va_start(ptr %ap)
53 ; WinX86_64 uses char* for va_list. Verify that the correct amount of bytes
54 ; are copied using va_copy.
57 ; CHECK: leaq 32(%rsp), [[REG_copy1:%[a-z]+]]
58 ; CHECK-DAG: movq [[REG_copy1]], 8(%rsp)
59 ; CHECK-DAG: movq [[REG_copy1]], (%rsp)
61 define win64cc void @copy1(i64 %a0, ...) nounwind {
63 %ap = alloca ptr, align 8
64 %cp = alloca ptr, align 8
65 call void @llvm.va_start(ptr %ap)
66 call void @llvm.va_copy(ptr %cp, ptr %ap)
71 ; CHECK: leaq 56(%rsp), [[REG_copy4:%[a-z]+]]
72 ; CHECK: movq [[REG_copy4]], 8(%rsp)
73 ; CHECK: movq [[REG_copy4]], (%rsp)
75 define win64cc void @copy4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
77 %ap = alloca ptr, align 8
78 %cp = alloca ptr, align 8
79 call void @llvm.va_start(ptr %ap)
80 call void @llvm.va_copy(ptr %cp, ptr %ap)
85 ; va_start (optimized away as overwritten by va_arg)
87 ; CHECK: leaq 52(%rsp), [[REG_arg4_2:%[a-z]+]]
88 ; CHECK: movq [[REG_arg4_2]], (%rsp)
89 ; CHECK: movl 48(%rsp), %eax
91 define win64cc i32 @arg4(i64 %a0, i64 %a1, i64 %a2, i64 %a3, ...) nounwind {
93 %ap = alloca ptr, align 8
94 call void @llvm.va_start(ptr %ap)
95 %tmp = va_arg ptr %ap, i32