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 ; v9.5-A is not expected to change codegen without -mbranch-protection=+pc, so reuse V83A.
6 ; RUN: llc -mtriple=aarch64 -mattr=v9.5a < %s | FileCheck --check-prefixes=CHECK,V83A %s
8 define i32 @leaf(i32 %x) {
15 define i32 @leaf_sign_none(i32 %x) {
16 ; CHECK-LABEL: leaf_sign_none:
22 define i32 @leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" {
23 ; CHECK-LABEL: leaf_sign_non_leaf:
29 define i32 @leaf_sign_all(i32 %x) "sign-return-address"="all" {
30 ; COMPAT-LABEL: leaf_sign_all:
32 ; COMPAT-NEXT: hint #25
33 ; COMPAT-NEXT: .cfi_negate_ra_state
34 ; COMPAT-NEXT: hint #29
37 ; V83A-LABEL: leaf_sign_all:
40 ; V83A-NEXT: .cfi_negate_ra_state
45 define i64 @leaf_clobbers_lr(i64 %x) "sign-return-address"="non-leaf" {
46 ; COMPAT-LABEL: leaf_clobbers_lr:
48 ; COMPAT-NEXT: hint #25
49 ; COMPAT-NEXT: .cfi_negate_ra_state
50 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
51 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
52 ; COMPAT-NEXT: .cfi_offset w30, -16
54 ; COMPAT-NEXT: mov x30, x0
55 ; COMPAT-NEXT: //NO_APP
56 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
57 ; COMPAT-NEXT: hint #29
60 ; V83A-LABEL: leaf_clobbers_lr:
63 ; V83A-NEXT: .cfi_negate_ra_state
64 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
65 ; V83A-NEXT: .cfi_def_cfa_offset 16
66 ; V83A-NEXT: .cfi_offset w30, -16
68 ; V83A-NEXT: mov x30, x0
70 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
72 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1
78 define i32 @non_leaf_sign_all(i32 %x) "sign-return-address"="all" {
79 ; COMPAT-LABEL: non_leaf_sign_all:
81 ; COMPAT-NEXT: hint #25
82 ; COMPAT-NEXT: .cfi_negate_ra_state
83 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
84 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
85 ; COMPAT-NEXT: .cfi_offset w30, -16
87 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
88 ; COMPAT-NEXT: hint #29
91 ; V83A-LABEL: non_leaf_sign_all:
94 ; V83A-NEXT: .cfi_negate_ra_state
95 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
96 ; V83A-NEXT: .cfi_def_cfa_offset 16
97 ; V83A-NEXT: .cfi_offset w30, -16
99 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
101 %call = call i32 @foo(i32 %x)
105 define i32 @non_leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" {
106 ; COMPAT-LABEL: non_leaf_sign_non_leaf:
108 ; COMPAT-NEXT: hint #25
109 ; COMPAT-NEXT: .cfi_negate_ra_state
110 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
111 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
112 ; COMPAT-NEXT: .cfi_offset w30, -16
113 ; COMPAT-NEXT: bl foo
114 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
115 ; COMPAT-NEXT: hint #29
118 ; V83A-LABEL: non_leaf_sign_non_leaf:
121 ; V83A-NEXT: .cfi_negate_ra_state
122 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
123 ; V83A-NEXT: .cfi_def_cfa_offset 16
124 ; V83A-NEXT: .cfi_offset w30, -16
126 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
128 %call = call i32 @foo(i32 %x)
132 ; Should not use the RETAA instruction.
133 define i32 @non_leaf_scs(i32 %x) "sign-return-address"="non-leaf" shadowcallstack "target-features"="+v8.3a,+reserve-x18" {
134 ; CHECK-LABEL: non_leaf_scs:
136 ; CHECK-NEXT: str x30, [x18], #8
137 ; CHECK-NEXT: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 //
138 ; CHECK-NEXT: paciasp
139 ; CHECK-NEXT: .cfi_negate_ra_state
140 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
141 ; CHECK-NEXT: .cfi_def_cfa_offset 16
142 ; CHECK-NEXT: .cfi_offset w30, -16
144 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
145 ; CHECK-NEXT: autiasp
146 ; CHECK-NEXT: ldr x30, [x18, #-8]!
148 %call = call i32 @foo(i32 %x)
152 define i32 @leaf_sign_all_v83(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" {
153 ; CHECK-LABEL: leaf_sign_all_v83:
155 ; CHECK-NEXT: paciasp
156 ; CHECK-NEXT: .cfi_negate_ra_state
161 declare fastcc i64 @bar(i64)
163 define fastcc void @spill_lr_and_tail_call(i64 %x) "sign-return-address"="all" {
164 ; COMPAT-LABEL: spill_lr_and_tail_call:
166 ; COMPAT-NEXT: hint #25
167 ; COMPAT-NEXT: .cfi_negate_ra_state
168 ; COMPAT-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
169 ; COMPAT-NEXT: .cfi_def_cfa_offset 16
170 ; COMPAT-NEXT: .cfi_offset w30, -16
172 ; COMPAT-NEXT: mov x30, x0
173 ; COMPAT-NEXT: //NO_APP
174 ; COMPAT-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
175 ; COMPAT-NEXT: hint #29
178 ; V83A-LABEL: spill_lr_and_tail_call:
181 ; V83A-NEXT: .cfi_negate_ra_state
182 ; V83A-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
183 ; V83A-NEXT: .cfi_def_cfa_offset 16
184 ; V83A-NEXT: .cfi_offset w30, -16
186 ; V83A-NEXT: mov x30, x0
187 ; V83A-NEXT: //NO_APP
188 ; V83A-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
191 call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1
192 tail call fastcc i64 @bar(i64 %x)
196 define i32 @leaf_sign_all_a_key(i32 %x) "sign-return-address"="all" "sign-return-address-key"="a_key" {
197 ; COMPAT-LABEL: leaf_sign_all_a_key:
199 ; COMPAT-NEXT: hint #25
200 ; COMPAT-NEXT: .cfi_negate_ra_state
201 ; COMPAT-NEXT: hint #29
204 ; V83A-LABEL: leaf_sign_all_a_key:
207 ; V83A-NEXT: .cfi_negate_ra_state
212 define i32 @leaf_sign_all_b_key(i32 %x) "sign-return-address"="all" "sign-return-address-key"="b_key" {
213 ; COMPAT-LABEL: leaf_sign_all_b_key:
215 ; COMPAT-NEXT: .cfi_b_key_frame
216 ; COMPAT-NEXT: hint #27
217 ; COMPAT-NEXT: .cfi_negate_ra_state
218 ; COMPAT-NEXT: hint #31
221 ; V83A-LABEL: leaf_sign_all_b_key:
223 ; V83A-NEXT: .cfi_b_key_frame
225 ; V83A-NEXT: .cfi_negate_ra_state
230 define i32 @leaf_sign_all_v83_b_key(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" "sign-return-address-key"="b_key" {
231 ; CHECK-LABEL: leaf_sign_all_v83_b_key:
233 ; CHECK-NEXT: .cfi_b_key_frame
234 ; CHECK-NEXT: pacibsp
235 ; CHECK-NEXT: .cfi_negate_ra_state
240 ; Note that BTI instruction is not needed before PACIASP.
241 define i32 @leaf_sign_all_a_key_bti(i32 %x) "sign-return-address"="all" "sign-return-address-key"="a_key" "branch-target-enforcement"{
242 ; COMPAT-LABEL: leaf_sign_all_a_key_bti:
244 ; COMPAT-NEXT: hint #25
245 ; COMPAT-NEXT: .cfi_negate_ra_state
246 ; COMPAT-NEXT: hint #29
249 ; V83A-LABEL: leaf_sign_all_a_key_bti:
252 ; V83A-NEXT: .cfi_negate_ra_state
257 ; Note that BTI instruction is not needed before PACIBSP.
258 define i32 @leaf_sign_all_b_key_bti(i32 %x) "sign-return-address"="all" "sign-return-address-key"="b_key" "branch-target-enforcement"{
259 ; COMPAT-LABEL: leaf_sign_all_b_key_bti:
261 ; COMPAT-NEXT: .cfi_b_key_frame
262 ; COMPAT-NEXT: hint #27
263 ; COMPAT-NEXT: .cfi_negate_ra_state
264 ; COMPAT-NEXT: hint #31
267 ; V83A-LABEL: leaf_sign_all_b_key_bti:
269 ; V83A-NEXT: .cfi_b_key_frame
271 ; V83A-NEXT: .cfi_negate_ra_state
276 ; Note that BTI instruction is not needed before PACIBSP.
277 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" {
278 ; CHECK-LABEL: leaf_sign_all_v83_b_key_bti:
280 ; CHECK-NEXT: .cfi_b_key_frame
281 ; CHECK-NEXT: pacibsp
282 ; CHECK-NEXT: .cfi_negate_ra_state