1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=aarch64 < %s | FileCheck --check-prefixes=CHECK,COMPAT %s
3 ; RUN: llc -mtriple=aarch64 -mattr=v8.3a < %s | FileCheck --check-prefixes=CHECK,V83A %s
5 define i32 @leaf(i32 %x) {
12 define i32 @leaf_sign_none(i32 %x) "sign-return-address"="none" {
13 ; CHECK-LABEL: leaf_sign_none:
19 define i32 @leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" {
20 ; CHECK-LABEL: leaf_sign_non_leaf:
26 define i32 @leaf_sign_all(i32 %x) "sign-return-address"="all" {
27 ; COMPAT-LABEL: leaf_sign_all:
29 ; COMPAT-NEXT: hint #25
30 ; COMPAT-NEXT: .cfi_negate_ra_state
31 ; COMPAT-NEXT: hint #29
34 ; V83A-LABEL: leaf_sign_all:
37 ; V83A-NEXT: .cfi_negate_ra_state
42 define i64 @leaf_clobbers_lr(i64 %x) "sign-return-address"="non-leaf" {
43 ; COMPAT-LABEL: leaf_clobbers_lr:
45 ; COMPAT-NEXT: hint #25
46 ; COMPAT-NEXT: .cfi_negate_ra_state
47 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
48 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
49 ; COMPAT-NEXT: .cfi_offset w30, -16
51 ; COMPAT-NEXT: mov x30, x0
52 ; COMPAT-NEXT: //NO_APP
53 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
54 ; COMPAT-NEXT: hint #29
57 ; V83A-LABEL: leaf_clobbers_lr:
60 ; V83A-NEXT: .cfi_negate_ra_state
61 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
62 ; V83A-NEXT: .cfi_def_cfa_offset 16
63 ; V83A-NEXT: .cfi_offset w30, -16
65 ; V83A-NEXT: mov x30, x0
67 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
69 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1
75 define i32 @non_leaf_sign_all(i32 %x) "sign-return-address"="all" {
76 ; COMPAT-LABEL: non_leaf_sign_all:
78 ; COMPAT-NEXT: hint #25
79 ; COMPAT-NEXT: .cfi_negate_ra_state
80 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
81 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
82 ; COMPAT-NEXT: .cfi_offset w30, -16
84 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
85 ; COMPAT-NEXT: hint #29
88 ; V83A-LABEL: non_leaf_sign_all:
91 ; V83A-NEXT: .cfi_negate_ra_state
92 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
93 ; V83A-NEXT: .cfi_def_cfa_offset 16
94 ; V83A-NEXT: .cfi_offset w30, -16
96 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
98 %call = call i32 @foo(i32 %x)
102 define i32 @non_leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" {
103 ; COMPAT-LABEL: non_leaf_sign_non_leaf:
105 ; COMPAT-NEXT: hint #25
106 ; COMPAT-NEXT: .cfi_negate_ra_state
107 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
108 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
109 ; COMPAT-NEXT: .cfi_offset w30, -16
110 ; COMPAT-NEXT: bl foo
111 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
112 ; COMPAT-NEXT: hint #29
115 ; V83A-LABEL: non_leaf_sign_non_leaf:
118 ; V83A-NEXT: .cfi_negate_ra_state
119 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
120 ; V83A-NEXT: .cfi_def_cfa_offset 16
121 ; V83A-NEXT: .cfi_offset w30, -16
123 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
125 %call = call i32 @foo(i32 %x)
129 ; Should not use the RETAA instruction.
130 define i32 @non_leaf_scs(i32 %x) "sign-return-address"="non-leaf" shadowcallstack "target-features"="+v8.3a,+reserve-x18" {
131 ; CHECK-LABEL: non_leaf_scs:
133 ; CHECK-NEXT: str x30, [x18], #8
134 ; CHECK-NEXT: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 //
135 ; CHECK-NEXT: paciasp
136 ; CHECK-NEXT: .cfi_negate_ra_state
137 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
138 ; CHECK-NEXT: .cfi_def_cfa_offset 16
139 ; CHECK-NEXT: .cfi_offset w30, -16
141 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
142 ; CHECK-NEXT: autiasp
143 ; CHECK-NEXT: ldr x30, [x18, #-8]!
145 %call = call i32 @foo(i32 %x)
149 define i32 @leaf_sign_all_v83(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" {
150 ; CHECK-LABEL: leaf_sign_all_v83:
152 ; CHECK-NEXT: paciasp
153 ; CHECK-NEXT: .cfi_negate_ra_state
158 declare fastcc i64 @bar(i64)
160 define fastcc void @spill_lr_and_tail_call(i64 %x) "sign-return-address"="all" {
161 ; COMPAT-LABEL: spill_lr_and_tail_call:
163 ; COMPAT-NEXT: hint #25
164 ; COMPAT-NEXT: .cfi_negate_ra_state
165 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
166 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
167 ; COMPAT-NEXT: .cfi_offset w30, -16
169 ; COMPAT-NEXT: mov x30, x0
170 ; COMPAT-NEXT: //NO_APP
171 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
172 ; COMPAT-NEXT: hint #29
175 ; V83A-LABEL: spill_lr_and_tail_call:
178 ; V83A-NEXT: .cfi_negate_ra_state
179 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
180 ; V83A-NEXT: .cfi_def_cfa_offset 16
181 ; V83A-NEXT: .cfi_offset w30, -16
183 ; V83A-NEXT: mov x30, x0
184 ; V83A-NEXT: //NO_APP
185 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
188 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1
189 tail call fastcc i64 @bar(i64 %x)
193 define i32 @leaf_sign_all_a_key(i32 %x) "sign-return-address"="all" "sign-return-address-key"="a_key" {
194 ; COMPAT-LABEL: leaf_sign_all_a_key:
196 ; COMPAT-NEXT: hint #25
197 ; COMPAT-NEXT: .cfi_negate_ra_state
198 ; COMPAT-NEXT: hint #29
201 ; V83A-LABEL: leaf_sign_all_a_key:
204 ; V83A-NEXT: .cfi_negate_ra_state
209 define i32 @leaf_sign_all_b_key(i32 %x) "sign-return-address"="all" "sign-return-address-key"="b_key" {
210 ; COMPAT-LABEL: leaf_sign_all_b_key:
212 ; COMPAT-NEXT: .cfi_b_key_frame
213 ; COMPAT-NEXT: hint #27
214 ; COMPAT-NEXT: .cfi_negate_ra_state
215 ; COMPAT-NEXT: hint #31
218 ; V83A-LABEL: leaf_sign_all_b_key:
220 ; V83A-NEXT: .cfi_b_key_frame
222 ; V83A-NEXT: .cfi_negate_ra_state
227 define i32 @leaf_sign_all_v83_b_key(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" "sign-return-address-key"="b_key" {
228 ; CHECK-LABEL: leaf_sign_all_v83_b_key:
230 ; CHECK-NEXT: .cfi_b_key_frame
231 ; CHECK-NEXT: pacibsp
232 ; CHECK-NEXT: .cfi_negate_ra_state
237 ; Note that BTI instruction is not needed before PACIASP.
238 define i32 @leaf_sign_all_a_key_bti(i32 %x) "sign-return-address"="all" "sign-return-address-key"="a_key" "branch-target-enforcement"="true"{
239 ; COMPAT-LABEL: leaf_sign_all_a_key_bti:
241 ; COMPAT-NEXT: hint #25
242 ; COMPAT-NEXT: .cfi_negate_ra_state
243 ; COMPAT-NEXT: hint #29
246 ; V83A-LABEL: leaf_sign_all_a_key_bti:
249 ; V83A-NEXT: .cfi_negate_ra_state
254 ; Note that BTI instruction is not needed before PACIBSP.
255 define i32 @leaf_sign_all_b_key_bti(i32 %x) "sign-return-address"="all" "sign-return-address-key"="b_key" "branch-target-enforcement"="true"{
256 ; COMPAT-LABEL: leaf_sign_all_b_key_bti:
258 ; COMPAT-NEXT: .cfi_b_key_frame
259 ; COMPAT-NEXT: hint #27
260 ; COMPAT-NEXT: .cfi_negate_ra_state
261 ; COMPAT-NEXT: hint #31
264 ; V83A-LABEL: leaf_sign_all_b_key_bti:
266 ; V83A-NEXT: .cfi_b_key_frame
268 ; V83A-NEXT: .cfi_negate_ra_state
273 ; Note that BTI instruction is not needed before PACIBSP.
274 define i32 @leaf_sign_all_v83_b_key_bti(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" "sign-return-address-key"="b_key" "branch-target-enforcement"="true" {
275 ; CHECK-LABEL: leaf_sign_all_v83_b_key_bti:
277 ; CHECK-NEXT: .cfi_b_key_frame
278 ; CHECK-NEXT: pacibsp
279 ; CHECK-NEXT: .cfi_negate_ra_state