1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -mtriple=aarch64-unknown-linux-gnu -mattr=+sme -S -passes=inline < %s | FileCheck %s
4 declare void @inlined_body()
7 ; Define some functions that will be called by the functions below.
8 ; These just call a '...body()' function. If we see the call to one of
9 ; these functions being replaced by '...body()', then we know it has been
13 define void @nonza_callee() {
14 ; CHECK-LABEL: define void @nonza_callee
15 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
17 ; CHECK-NEXT: call void @inlined_body()
18 ; CHECK-NEXT: ret void
21 call void @inlined_body()
25 define void @shared_za_callee() "aarch64_inout_za" {
26 ; CHECK-LABEL: define void @shared_za_callee
27 ; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
29 ; CHECK-NEXT: call void @inlined_body()
30 ; CHECK-NEXT: ret void
33 call void @inlined_body()
37 define void @new_za_callee() "aarch64_new_za" {
38 ; CHECK-LABEL: define void @new_za_callee
39 ; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
40 ; CHECK-NEXT: call void @inlined_body()
41 ; CHECK-NEXT: ret void
43 call void @inlined_body()
48 ; Now test that inlining only happens when no lazy-save is needed.
49 ; Test for a number of combinations, where:
51 ; S Shared ZA interface
55 ; [ ] N -> S (This combination is invalid)
57 define void @nonza_caller_nonza_callee_inline() {
58 ; CHECK-LABEL: define void @nonza_caller_nonza_callee_inline
59 ; CHECK-SAME: () #[[ATTR0]] {
61 ; CHECK-NEXT: call void @inlined_body()
62 ; CHECK-NEXT: ret void
65 call void @nonza_callee()
70 ; [ ] N -> S (This combination is invalid)
72 define void @nonza_caller_new_za_callee_dont_inline() {
73 ; CHECK-LABEL: define void @nonza_caller_new_za_callee_dont_inline
74 ; CHECK-SAME: () #[[ATTR0]] {
76 ; CHECK-NEXT: call void @new_za_callee()
77 ; CHECK-NEXT: ret void
80 call void @new_za_callee()
87 define void @new_za_caller_nonza_callee_inline() "aarch64_new_za" {
88 ; CHECK-LABEL: define void @new_za_caller_nonza_callee_inline
89 ; CHECK-SAME: () #[[ATTR2]] {
91 ; CHECK-NEXT: call void @inlined_body()
92 ; CHECK-NEXT: ret void
95 call void @nonza_callee()
102 define void @new_za_caller_shared_za_callee_inline() "aarch64_new_za" {
103 ; CHECK-LABEL: define void @new_za_caller_shared_za_callee_inline
104 ; CHECK-SAME: () #[[ATTR2]] {
106 ; CHECK-NEXT: call void @inlined_body()
107 ; CHECK-NEXT: ret void
110 call void @shared_za_callee()
117 define void @new_za_caller_new_za_callee_dont_inline() "aarch64_new_za" {
118 ; CHECK-LABEL: define void @new_za_caller_new_za_callee_dont_inline
119 ; CHECK-SAME: () #[[ATTR2]] {
121 ; CHECK-NEXT: call void @new_za_callee()
122 ; CHECK-NEXT: ret void
125 call void @new_za_callee()
132 define void @shared_za_caller_nonza_callee_inline() "aarch64_inout_za" {
133 ; CHECK-LABEL: define void @shared_za_caller_nonza_callee_inline
134 ; CHECK-SAME: () #[[ATTR1]] {
136 ; CHECK-NEXT: call void @inlined_body()
137 ; CHECK-NEXT: ret void
140 call void @nonza_callee()
147 define void @shared_za_caller_new_za_callee_dont_inline() "aarch64_inout_za" {
148 ; CHECK-LABEL: define void @shared_za_caller_new_za_callee_dont_inline
149 ; CHECK-SAME: () #[[ATTR1]] {
151 ; CHECK-NEXT: call void @new_za_callee()
152 ; CHECK-NEXT: ret void
155 call void @new_za_callee()
162 define void @shared_za_caller_shared_za_callee_inline() "aarch64_inout_za" {
163 ; CHECK-LABEL: define void @shared_za_caller_shared_za_callee_inline
164 ; CHECK-SAME: () #[[ATTR1]] {
166 ; CHECK-NEXT: call void @inlined_body()
167 ; CHECK-NEXT: ret void
170 call void @shared_za_callee()
174 define void @private_za_callee_call_za_disable() {
175 ; CHECK-LABEL: define void @private_za_callee_call_za_disable
176 ; CHECK-SAME: () #[[ATTR0]] {
177 ; CHECK-NEXT: call void @__arm_za_disable()
178 ; CHECK-NEXT: ret void
180 call void @__arm_za_disable()
184 define void @shared_za_caller_private_za_callee_call_za_disable() "aarch64_inout_za" {
185 ; CHECK-LABEL: define void @shared_za_caller_private_za_callee_call_za_disable
186 ; CHECK-SAME: () #[[ATTR1]] {
187 ; CHECK-NEXT: call void @private_za_callee_call_za_disable()
188 ; CHECK-NEXT: ret void
190 call void @private_za_callee_call_za_disable()
194 define void @private_za_callee_call_tpidr2_save() {
195 ; CHECK-LABEL: define void @private_za_callee_call_tpidr2_save
196 ; CHECK-SAME: () #[[ATTR0]] {
197 ; CHECK-NEXT: call void @__arm_tpidr2_save()
198 ; CHECK-NEXT: ret void
200 call void @__arm_tpidr2_save()
204 define void @shared_za_caller_private_za_callee_call_tpidr2_save_dont_inline() "aarch64_inout_za" {
205 ; CHECK-LABEL: define void @shared_za_caller_private_za_callee_call_tpidr2_save_dont_inline
206 ; CHECK-SAME: () #[[ATTR1]] {
207 ; CHECK-NEXT: call void @private_za_callee_call_tpidr2_save()
208 ; CHECK-NEXT: ret void
210 call void @private_za_callee_call_tpidr2_save()
214 define void @private_za_callee_call_tpidr2_restore(ptr %ptr) {
215 ; CHECK-LABEL: define void @private_za_callee_call_tpidr2_restore
216 ; CHECK-SAME: (ptr [[PTR:%.*]]) #[[ATTR0]] {
217 ; CHECK-NEXT: call void @__arm_tpidr2_restore(ptr [[PTR]])
218 ; CHECK-NEXT: ret void
220 call void @__arm_tpidr2_restore(ptr %ptr)
224 define void @shared_za_caller_private_za_callee_call_tpidr2_restore_dont_inline(ptr %ptr) "aarch64_inout_za" {
225 ; CHECK-LABEL: define void @shared_za_caller_private_za_callee_call_tpidr2_restore_dont_inline
226 ; CHECK-SAME: (ptr [[PTR:%.*]]) #[[ATTR1]] {
227 ; CHECK-NEXT: call void @private_za_callee_call_tpidr2_restore(ptr [[PTR]])
228 ; CHECK-NEXT: ret void
230 call void @private_za_callee_call_tpidr2_restore(ptr %ptr)
234 define void @nonzt0_callee() {
235 ; CHECK-LABEL: define void @nonzt0_callee
236 ; CHECK-SAME: () #[[ATTR0]] {
237 ; CHECK-NEXT: call void asm sideeffect "
238 ; CHECK-NEXT: call void @inlined_body()
239 ; CHECK-NEXT: ret void
241 call void asm sideeffect "; inlineasm", ""()
242 call void @inlined_body()
246 define void @shared_zt0_caller_nonzt0_callee_dont_inline() "aarch64_inout_zt0" {
247 ; CHECK-LABEL: define void @shared_zt0_caller_nonzt0_callee_dont_inline
248 ; CHECK-SAME: () #[[ATTR3:[0-9]+]] {
249 ; CHECK-NEXT: call void @nonzt0_callee()
250 ; CHECK-NEXT: ret void
252 call void @nonzt0_callee()
256 define void @shared_zt0_callee() "aarch64_inout_zt0" {
257 ; CHECK-LABEL: define void @shared_zt0_callee
258 ; CHECK-SAME: () #[[ATTR3]] {
259 ; CHECK-NEXT: call void asm sideeffect "
260 ; CHECK-NEXT: call void @inlined_body()
261 ; CHECK-NEXT: ret void
263 call void asm sideeffect "; inlineasm", ""()
264 call void @inlined_body()
268 define void @shared_zt0_caller_shared_zt0_callee_inline() "aarch64_inout_zt0" {
269 ; CHECK-LABEL: define void @shared_zt0_caller_shared_zt0_callee_inline
270 ; CHECK-SAME: () #[[ATTR3]] {
271 ; CHECK-NEXT: call void asm sideeffect "
272 ; CHECK-NEXT: call void @inlined_body()
273 ; CHECK-NEXT: ret void
275 call void @shared_zt0_callee()
279 declare void @__arm_za_disable()
280 declare void @__arm_tpidr2_save()
281 declare void @__arm_tpidr2_restore(ptr)