1 ; RUN: llc -mtriple=arm64-apple-ios15 %s -o - | FileCheck %s --check-prefixes=CHECK-NOAUTH,CHECK
2 ; RUN: llc -mtriple=arm64-apple-ios15 -mcpu=apple-a13 %s -o - | FileCheck %s --check-prefixes=CHECK-NOAUTH,CHECK
3 ; RUN: llc -mtriple=arm64e-apple-ios15 %s -o - | FileCheck %s --check-prefixes=CHECK-AUTH,CHECK
5 ; Important details in prologue:
6 ; * x22 is stored just below x29
7 ; * Enough stack space is allocated for everything
8 define swifttailcc void @simple(ptr swiftasync %ctx) "frame-pointer"="all" {
10 ; CHECK: orr x29, x29, #0x100000000000000
11 ; CHECK: sub sp, sp, #32
12 ; CHECK: stp x29, x30, [sp, #16]
14 ; CHECK-NOAUTH-DAG: str x22, [sp, #8]
15 ; CHECK-AUTH: add x16, sp, #8
16 ; CHECK-AUTH: movk x16, #49946, lsl #48
17 ; CHECK-AUTH: mov x17, x22
18 ; CHECK-AUTH: pacdb x17, x16
19 ; CHECK-AUTH: str x17, [sp, #8]
21 ; CHECK-DAG: add x29, sp, #16
22 ; CHECK: .cfi_def_cfa w29, 16
23 ; CHECK: .cfi_offset w30, -8
24 ; CHECK: .cfi_offset w29, -16
28 ; CHECK: ldp x29, x30, [sp, #16]
29 ; CHECK: and x29, x29, #0xefffffffffffffff
30 ; CHECK: add sp, sp, #32
35 define swifttailcc void @more_csrs(ptr swiftasync %ctx) "frame-pointer"="all" {
36 ; CHECK-LABEL: more_csrs:
37 ; CHECK: orr x29, x29, #0x100000000000000
38 ; CHECK: str x23, [sp, #-32]!
39 ; CHECK: stp x29, x30, [sp, #16]
41 ; CHECK-NOAUTH-DAG: str x22, [sp, #8]
42 ; CHECK-AUTH: add x16, sp, #8
43 ; CHECK-AUTH: movk x16, #49946, lsl #48
44 ; CHECK-AUTH: mov x17, x22
45 ; CHECK-AUTH: pacdb x17, x16
46 ; CHECK-AUTH: str x17, [sp, #8]
48 ; CHECK-DAG: add x29, sp, #16
49 ; CHECK: .cfi_def_cfa w29, 16
50 ; CHECK: .cfi_offset w30, -8
51 ; CHECK: .cfi_offset w29, -16
52 ; CHECK: .cfi_offset w23, -32
56 ; CHECK: ldp x29, x30, [sp, #16]
57 ; CHECK: ldr x23, [sp], #32
58 ; CHECK: and x29, x29, #0xefffffffffffffff
59 call void asm sideeffect "", "~{x23}"()
63 define swifttailcc void @locals(ptr swiftasync %ctx) "frame-pointer"="all" {
64 ; CHECK-LABEL: locals:
65 ; CHECK: orr x29, x29, #0x100000000000000
66 ; CHECK: sub sp, sp, #64
67 ; CHECK: stp x29, x30, [sp, #48]
69 ; CHECK-NOAUTH-DAG: str x22, [sp, #40]
70 ; CHECK-AUTH: add x16, sp, #40
71 ; CHECK-AUTH: movk x16, #49946, lsl #48
72 ; CHECK-AUTH: mov x17, x22
73 ; CHECK-AUTH: pacdb x17, x16
74 ; CHECK-AUTH: str x17, [sp, #40]
76 ; CHECK-DAG: add x29, sp, #48
77 ; CHECK: .cfi_def_cfa w29, 16
78 ; CHECK: .cfi_offset w30, -8
79 ; CHECK: .cfi_offset w29, -16
86 ; CHECK: ldp x29, x30, [sp, #48]
87 ; CHECK: and x29, x29, #0xefffffffffffffff
88 ; CHECK: add sp, sp, #64
89 %var = alloca i32, i32 10
90 call void @bar(ptr %var)
94 define swifttailcc void @use_input_context(ptr swiftasync %ctx, ptr %ptr) "frame-pointer"="all" {
95 ; CHECK-LABEL: use_input_context:
97 ; CHECK-NOAUTH: str x22, [sp
98 ; CHECK-AUTH: mov x17, x22
101 ; CHECK: str x22, [x0]
103 store ptr %ctx, ptr %ptr
107 define swifttailcc ptr @context_in_func() "frame-pointer"="non-leaf" {
108 ; CHECK-LABEL: context_in_func:
110 ; CHECK-NOAUTH: str xzr, [sp, #8]
111 ; CHECK-AUTH: add x16, sp, #8
112 ; CHECK-AUTH: movk x16, #49946, lsl #48
113 ; CHECK-AUTH: mov x17, xzr
114 ; CHECK-AUTH: pacdb x17, x16
115 ; CHECK-AUTH: str x17, [sp, #8]
117 %ptr = call ptr @llvm.swift.async.context.addr()
121 define swifttailcc void @write_frame_context(ptr swiftasync %ctx, ptr %newctx) "frame-pointer"="non-leaf" {
122 ; CHECK-LABEL: write_frame_context:
123 ; CHECK: sub x[[ADDR:[0-9]+]], x29, #8
124 ; CHECK: str x0, [x[[ADDR]]]
125 %ptr = call ptr @llvm.swift.async.context.addr()
126 store ptr %newctx, ptr %ptr
130 define swifttailcc void @simple_fp_elim(ptr swiftasync %ctx) "frame-pointer"="non-leaf" {
131 ; CHECK-LABEL: simple_fp_elim:
132 ; CHECK-NOT: orr x29, x29, #0x100000000000000
137 define swifttailcc void @large_frame(ptr swiftasync %ctx) "frame-pointer"="all" {
138 ; CHECK-LABEL: large_frame:
139 ; CHECK: str x28, [sp, #-32]!
140 ; CHECK: stp x29, x30, [sp, #16]
141 ; CHECK-NOAUTH-DAG: str x22, [sp, #8]
142 ; CHECK-DAG: add x29, sp, #16
143 ; CHECK: sub sp, sp, #1024
145 ; CHECK: add sp, sp, #1024
146 ; CHECK: ldp x29, x30, [sp, #16]
147 ; CHECK: ldr x28, [sp], #32
149 %var = alloca i8, i32 1024
153 ; Important point is that there is just one 8-byte gap in the CSR region (right
154 ; now just above d8) to realign the stack.
155 define swifttailcc void @two_unpaired_csrs(ptr swiftasync) "frame-pointer"="all" {
156 ; CHECK-LABEL: two_unpaired_csrs:
157 ; CHECK: str d8, [sp, #-48]!
158 ; CHECK: str x19, [sp, #16]
159 ; CHECK: stp x29, x30, [sp, #32]
160 ; CHECK-NOAUTH-DAG: str x22, [sp, #24]
161 ; CHECK-DAG: add x29, sp, #32
163 ; CHECK: .cfi_def_cfa w29, 16
164 ; CHECK: .cfi_offset w30, -8
165 ; CHECK: .cfi_offset w29, -16
166 ; CHECK: .cfi_offset w19, -32
167 ; CHECK: .cfi_offset b8, -48
169 call void asm "","~{x19},~{d8}"()
170 call swifttailcc void @bar(ptr undef)
173 declare swifttailcc void @bar(ptr)
174 declare ptr @llvm.swift.async.context.addr()