1; RUN: llc -mtriple=aarch64-windows-msvc -frame-pointer=all %s -o - | FileCheck %s
2; RUN: llc -mtriple=aarch64-windows-msvc -fast-isel -frame-pointer=all %s -o - | FileCheck %s
3; RUN: llc -mtriple=aarch64-windows-msvc %s -o - | FileCheck %s --check-prefix=NOFP
4; RUN: llc -mtriple=aarch64-windows-msvc -fast-isel %s -o - | FileCheck %s --check-prefix=NOFP
5
6@env2 = common dso_local global [24 x i64]* null, align 8
7
8define dso_local void @bar() {
9  %1 = call i8* @llvm.sponentry()
10  %2 = load [24 x i64]*, [24 x i64]** @env2, align 8
11  %3 = getelementptr inbounds [24 x i64], [24 x i64]* %2, i32 0, i32 0
12  %4 = bitcast i64* %3 to i8*
13  %5 = call i32 @_setjmpex(i8* %4, i8* %1) #2
14  ret void
15}
16
17; CHECK: bar:
18; CHECK: mov     x29, sp
19; CHECK: add     x1, x29, #16
20; CHECK: bl      _setjmpex
21
22; NOFP: str     x30, [sp, #-16]!
23; NOFP: add     x1, sp, #16
24
25define dso_local void @foo([24 x i64]*) {
26  %2 = alloca [24 x i64]*, align 8
27  %3 = alloca i32, align 4
28  %4 = alloca [100 x i32], align 4
29  store [24 x i64]* %0, [24 x i64]** %2, align 8
30  %5 = call i8* @llvm.sponentry()
31  %6 = load [24 x i64]*, [24 x i64]** %2, align 8
32  %7 = getelementptr inbounds [24 x i64], [24 x i64]* %6, i32 0, i32 0
33  %8 = bitcast i64* %7 to i8*
34  %9 = call i32 @_setjmpex(i8* %8, i8* %5)
35  store i32 %9, i32* %3, align 4
36  ret void
37}
38
39; CHECK: foo:
40; CHECK: sub     sp, sp, #448
41; CHECK: add     x29, sp, #424
42; CHECK: add     x1, x29, #24
43; CHECK: bl      _setjmpex
44
45; NOFP: sub     sp, sp, #432
46; NOFP: add     x1, sp, #432
47
48define dso_local void @var_args(i8*, ...) {
49  %2 = alloca i8*, align 8
50  %3 = alloca i8*, align 8
51  store i8* %0, i8** %2, align 8
52  %4 = bitcast i8** %3 to i8*
53  call void @llvm.va_start(i8* %4)
54  %5 = load i8*, i8** %3, align 8
55  %6 = getelementptr inbounds i8, i8* %5, i64 8
56  store i8* %6, i8** %3, align 8
57  %7 = bitcast i8* %5 to i32*
58  %8 = load i32, i32* %7, align 8
59  %9 = bitcast i8** %3 to i8*
60  call void @llvm.va_end(i8* %9)
61  %10 = call i8* @llvm.sponentry()
62  %11 = load [24 x i64]*, [24 x i64]** @env2, align 8
63  %12 = getelementptr inbounds [24 x i64], [24 x i64]* %11, i32 0, i32 0
64  %13 = bitcast i64* %12 to i8*
65  %14 = call i32 @_setjmpex(i8* %13, i8* %10) #3
66  ret void
67}
68
69; CHECK: var_args:
70; CHECK: sub     sp, sp, #96
71; CHECK: add     x29, sp, #16
72; CHECK: add     x1, x29, #80
73; CHECK: bl      _setjmpex
74
75; NOFP: sub     sp, sp, #96
76; NOFP: add     x1, sp, #96
77
78define dso_local void @manyargs(i64 %x1, i64 %x2, i64 %x3, i64 %x4, i64 %x5, i64 %x6, i64 %x7, i64 %x8, i64 %x9, i64 %x10) {
79  %1 = call i8* @llvm.sponentry()
80  %2 = load [24 x i64]*, [24 x i64]** @env2, align 8
81  %3 = getelementptr inbounds [24 x i64], [24 x i64]* %2, i32 0, i32 0
82  %4 = bitcast i64* %3 to i8*
83  %5 = call i32 @_setjmpex(i8* %4, i8* %1) #2
84  ret void
85}
86
87; CHECK: manyargs:
88; CHECK: stp     x29, x30, [sp, #-16]!
89; CHECK: add     x1, x29, #16
90
91; NOFP: str     x30, [sp, #-16]!
92; NOFP: add     x1, sp, #16
93
94; Function Attrs: nounwind readnone
95declare i8* @llvm.sponentry()
96
97; Function Attrs: returns_twice
98declare dso_local i32 @_setjmpex(i8*, i8*)
99
100; Function Attrs: nounwind
101declare void @llvm.va_start(i8*) #1
102
103; Function Attrs: nounwind
104declare void @llvm.va_end(i8*) #1
105