1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs | FileCheck %s -DL="L" --check-prefixes=ALL,NOFPAC
3 ; RUN: llc < %s -mtriple arm64e-apple-darwin -mattr=+fpac -verify-machineinstrs | FileCheck %s -DL="L" --check-prefixes=ALL,FPAC
4 ; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs | FileCheck %s -DL=".L" --check-prefixes=ALL,NOFPAC
5 ; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -mattr=+fpac -verify-machineinstrs | FileCheck %s -DL=".L" --check-prefixes=ALL,FPAC
7 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
9 define i64 @test_auth_ia(i64 %arg, i64 %arg1) {
10 ; ALL-LABEL: test_auth_ia:
12 ; ALL-NEXT: mov x16, x0
13 ; ALL-NEXT: autia x16, x1
14 ; ALL-NEXT: mov x0, x16
16 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1)
20 define i64 @test_auth_ia_zero(i64 %arg) {
21 ; ALL-LABEL: test_auth_ia_zero:
23 ; ALL-NEXT: mov x16, x0
24 ; ALL-NEXT: autiza x16
25 ; ALL-NEXT: mov x0, x16
27 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 0)
31 define i64 @test_auth_ib(i64 %arg, i64 %arg1) {
32 ; ALL-LABEL: test_auth_ib:
34 ; ALL-NEXT: mov x16, x0
35 ; ALL-NEXT: autib x16, x1
36 ; ALL-NEXT: mov x0, x16
38 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 %arg1)
42 define i64 @test_auth_ib_zero(i64 %arg) {
43 ; ALL-LABEL: test_auth_ib_zero:
45 ; ALL-NEXT: mov x16, x0
46 ; ALL-NEXT: autizb x16
47 ; ALL-NEXT: mov x0, x16
49 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 0)
53 define i64 @test_auth_da(i64 %arg, i64 %arg1) {
54 ; ALL-LABEL: test_auth_da:
56 ; ALL-NEXT: mov x16, x0
57 ; ALL-NEXT: autda x16, x1
58 ; ALL-NEXT: mov x0, x16
60 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %arg1)
64 define i64 @test_auth_da_zero(i64 %arg) {
65 ; ALL-LABEL: test_auth_da_zero:
67 ; ALL-NEXT: mov x16, x0
68 ; ALL-NEXT: autdza x16
69 ; ALL-NEXT: mov x0, x16
71 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 0)
75 define i64 @test_auth_db(i64 %arg, i64 %arg1) {
76 ; ALL-LABEL: test_auth_db:
78 ; ALL-NEXT: mov x16, x0
79 ; ALL-NEXT: autdb x16, x1
80 ; ALL-NEXT: mov x0, x16
82 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 %arg1)
86 define i64 @test_auth_db_zero(i64 %arg) {
87 ; ALL-LABEL: test_auth_db_zero:
89 ; ALL-NEXT: mov x16, x0
90 ; ALL-NEXT: autdzb x16
91 ; ALL-NEXT: mov x0, x16
93 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 0)
97 ; Note that this might seem like a no-op but is actually a valid way to enforce
98 ; the validity of a signature.
99 define i64 @test_resign_ia_ia(i64 %arg, i64 %arg1, i64 %arg2) {
100 ; NOFPAC-LABEL: test_resign_ia_ia:
102 ; NOFPAC-NEXT: mov x16, x0
103 ; NOFPAC-NEXT: autia x16, x1
104 ; NOFPAC-NEXT: mov x17, x16
105 ; NOFPAC-NEXT: xpaci x17
106 ; NOFPAC-NEXT: cmp x16, x17
107 ; NOFPAC-NEXT: b.eq [[L]]auth_success_0
108 ; NOFPAC-NEXT: mov x16, x17
109 ; NOFPAC-NEXT: b [[L]]resign_end_0
110 ; NOFPAC-NEXT: Lauth_success_0:
111 ; NOFPAC-NEXT: pacia x16, x2
112 ; NOFPAC-NEXT: Lresign_end_0:
113 ; NOFPAC-NEXT: mov x0, x16
116 ; FPAC-LABEL: test_resign_ia_ia:
118 ; FPAC-NEXT: mov x16, x0
119 ; FPAC-NEXT: autia x16, x1
120 ; FPAC-NEXT: pacia x16, x2
121 ; FPAC-NEXT: mov x0, x16
123 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 %arg1, i32 0, i64 %arg2)
127 define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) {
128 ; NOFPAC-LABEL: test_resign_ib_ia:
130 ; NOFPAC-NEXT: mov x16, x0
131 ; NOFPAC-NEXT: autib x16, x1
132 ; NOFPAC-NEXT: mov x17, x16
133 ; NOFPAC-NEXT: xpaci x17
134 ; NOFPAC-NEXT: cmp x16, x17
135 ; NOFPAC-NEXT: b.eq [[L]]auth_success_1
136 ; NOFPAC-NEXT: mov x16, x17
137 ; NOFPAC-NEXT: b [[L]]resign_end_1
138 ; NOFPAC-NEXT: Lauth_success_1:
139 ; NOFPAC-NEXT: pacia x16, x2
140 ; NOFPAC-NEXT: Lresign_end_1:
141 ; NOFPAC-NEXT: mov x0, x16
144 ; FPAC-LABEL: test_resign_ib_ia:
146 ; FPAC-NEXT: mov x16, x0
147 ; FPAC-NEXT: autib x16, x1
148 ; FPAC-NEXT: pacia x16, x2
149 ; FPAC-NEXT: mov x0, x16
151 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 1, i64 %arg1, i32 0, i64 %arg2)
155 define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) {
156 ; NOFPAC-LABEL: test_resign_da_ia:
158 ; NOFPAC-NEXT: mov x16, x0
159 ; NOFPAC-NEXT: autda x16, x1
160 ; NOFPAC-NEXT: mov x17, x16
161 ; NOFPAC-NEXT: xpacd x17
162 ; NOFPAC-NEXT: cmp x16, x17
163 ; NOFPAC-NEXT: b.eq [[L]]auth_success_2
164 ; NOFPAC-NEXT: mov x16, x17
165 ; NOFPAC-NEXT: b [[L]]resign_end_2
166 ; NOFPAC-NEXT: Lauth_success_2:
167 ; NOFPAC-NEXT: pacia x16, x2
168 ; NOFPAC-NEXT: Lresign_end_2:
169 ; NOFPAC-NEXT: mov x0, x16
172 ; FPAC-LABEL: test_resign_da_ia:
174 ; FPAC-NEXT: mov x16, x0
175 ; FPAC-NEXT: autda x16, x1
176 ; FPAC-NEXT: pacia x16, x2
177 ; FPAC-NEXT: mov x0, x16
179 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 0, i64 %arg2)
183 define i64 @test_resign_db_ia(i64 %arg, i64 %arg1, i64 %arg2) {
184 ; NOFPAC-LABEL: test_resign_db_ia:
186 ; NOFPAC-NEXT: mov x16, x0
187 ; NOFPAC-NEXT: autdb x16, x1
188 ; NOFPAC-NEXT: mov x17, x16
189 ; NOFPAC-NEXT: xpacd x17
190 ; NOFPAC-NEXT: cmp x16, x17
191 ; NOFPAC-NEXT: b.eq [[L]]auth_success_3
192 ; NOFPAC-NEXT: mov x16, x17
193 ; NOFPAC-NEXT: b [[L]]resign_end_3
194 ; NOFPAC-NEXT: Lauth_success_3:
195 ; NOFPAC-NEXT: pacia x16, x2
196 ; NOFPAC-NEXT: Lresign_end_3:
197 ; NOFPAC-NEXT: mov x0, x16
200 ; FPAC-LABEL: test_resign_db_ia:
202 ; FPAC-NEXT: mov x16, x0
203 ; FPAC-NEXT: autdb x16, x1
204 ; FPAC-NEXT: pacia x16, x2
205 ; FPAC-NEXT: mov x0, x16
207 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 0, i64 %arg2)
211 define i64 @test_resign_db_ib(i64 %arg, i64 %arg1, i64 %arg2) {
212 ; NOFPAC-LABEL: test_resign_db_ib:
214 ; NOFPAC-NEXT: mov x16, x0
215 ; NOFPAC-NEXT: autdb x16, x1
216 ; NOFPAC-NEXT: mov x17, x16
217 ; NOFPAC-NEXT: xpacd x17
218 ; NOFPAC-NEXT: cmp x16, x17
219 ; NOFPAC-NEXT: b.eq [[L]]auth_success_4
220 ; NOFPAC-NEXT: mov x16, x17
221 ; NOFPAC-NEXT: b [[L]]resign_end_4
222 ; NOFPAC-NEXT: Lauth_success_4:
223 ; NOFPAC-NEXT: pacib x16, x2
224 ; NOFPAC-NEXT: Lresign_end_4:
225 ; NOFPAC-NEXT: mov x0, x16
228 ; FPAC-LABEL: test_resign_db_ib:
230 ; FPAC-NEXT: mov x16, x0
231 ; FPAC-NEXT: autdb x16, x1
232 ; FPAC-NEXT: pacib x16, x2
233 ; FPAC-NEXT: mov x0, x16
235 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 1, i64 %arg2)
239 define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) {
240 ; NOFPAC-LABEL: test_resign_db_da:
242 ; NOFPAC-NEXT: mov x16, x0
243 ; NOFPAC-NEXT: autdb x16, x1
244 ; NOFPAC-NEXT: mov x17, x16
245 ; NOFPAC-NEXT: xpacd x17
246 ; NOFPAC-NEXT: cmp x16, x17
247 ; NOFPAC-NEXT: b.eq [[L]]auth_success_5
248 ; NOFPAC-NEXT: mov x16, x17
249 ; NOFPAC-NEXT: b [[L]]resign_end_5
250 ; NOFPAC-NEXT: Lauth_success_5:
251 ; NOFPAC-NEXT: pacda x16, x2
252 ; NOFPAC-NEXT: Lresign_end_5:
253 ; NOFPAC-NEXT: mov x0, x16
256 ; FPAC-LABEL: test_resign_db_da:
258 ; FPAC-NEXT: mov x16, x0
259 ; FPAC-NEXT: autdb x16, x1
260 ; FPAC-NEXT: pacda x16, x2
261 ; FPAC-NEXT: mov x0, x16
263 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 2, i64 %arg2)
267 define i64 @test_resign_db_db(i64 %arg, i64 %arg1, i64 %arg2) {
268 ; NOFPAC-LABEL: test_resign_db_db:
270 ; NOFPAC-NEXT: mov x16, x0
271 ; NOFPAC-NEXT: autdb x16, x1
272 ; NOFPAC-NEXT: mov x17, x16
273 ; NOFPAC-NEXT: xpacd x17
274 ; NOFPAC-NEXT: cmp x16, x17
275 ; NOFPAC-NEXT: b.eq [[L]]auth_success_6
276 ; NOFPAC-NEXT: mov x16, x17
277 ; NOFPAC-NEXT: b [[L]]resign_end_6
278 ; NOFPAC-NEXT: Lauth_success_6:
279 ; NOFPAC-NEXT: pacdb x16, x2
280 ; NOFPAC-NEXT: Lresign_end_6:
281 ; NOFPAC-NEXT: mov x0, x16
284 ; FPAC-LABEL: test_resign_db_db:
286 ; FPAC-NEXT: mov x16, x0
287 ; FPAC-NEXT: autdb x16, x1
288 ; FPAC-NEXT: pacdb x16, x2
289 ; FPAC-NEXT: mov x0, x16
291 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 3, i64 %arg2)
295 define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) {
296 ; NOFPAC-LABEL: test_resign_iza_db:
298 ; NOFPAC-NEXT: mov x16, x0
299 ; NOFPAC-NEXT: autiza x16
300 ; NOFPAC-NEXT: mov x17, x16
301 ; NOFPAC-NEXT: xpaci x17
302 ; NOFPAC-NEXT: cmp x16, x17
303 ; NOFPAC-NEXT: b.eq [[L]]auth_success_7
304 ; NOFPAC-NEXT: mov x16, x17
305 ; NOFPAC-NEXT: b [[L]]resign_end_7
306 ; NOFPAC-NEXT: Lauth_success_7:
307 ; NOFPAC-NEXT: pacdb x16, x2
308 ; NOFPAC-NEXT: Lresign_end_7:
309 ; NOFPAC-NEXT: mov x0, x16
312 ; FPAC-LABEL: test_resign_iza_db:
314 ; FPAC-NEXT: mov x16, x0
315 ; FPAC-NEXT: autiza x16
316 ; FPAC-NEXT: pacdb x16, x2
317 ; FPAC-NEXT: mov x0, x16
319 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 0, i32 3, i64 %arg2)
323 define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) {
324 ; NOFPAC-LABEL: test_resign_da_dzb:
326 ; NOFPAC-NEXT: mov x16, x0
327 ; NOFPAC-NEXT: autda x16, x1
328 ; NOFPAC-NEXT: mov x17, x16
329 ; NOFPAC-NEXT: xpacd x17
330 ; NOFPAC-NEXT: cmp x16, x17
331 ; NOFPAC-NEXT: b.eq [[L]]auth_success_8
332 ; NOFPAC-NEXT: mov x16, x17
333 ; NOFPAC-NEXT: b [[L]]resign_end_8
334 ; NOFPAC-NEXT: Lauth_success_8:
335 ; NOFPAC-NEXT: pacdzb x16
336 ; NOFPAC-NEXT: Lresign_end_8:
337 ; NOFPAC-NEXT: mov x0, x16
340 ; FPAC-LABEL: test_resign_da_dzb:
342 ; FPAC-NEXT: mov x16, x0
343 ; FPAC-NEXT: autda x16, x1
344 ; FPAC-NEXT: pacdzb x16
345 ; FPAC-NEXT: mov x0, x16
347 %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 3, i64 0)
351 define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" {
352 ; NOFPAC-LABEL: test_auth_trap_attribute:
354 ; NOFPAC-NEXT: mov x16, x0
355 ; NOFPAC-NEXT: autia x16, x1
356 ; NOFPAC-NEXT: mov x17, x16
357 ; NOFPAC-NEXT: xpaci x17
358 ; NOFPAC-NEXT: cmp x16, x17
359 ; NOFPAC-NEXT: b.eq [[L]]auth_success_9
360 ; NOFPAC-NEXT: brk #0xc470
361 ; NOFPAC-NEXT: Lauth_success_9:
362 ; NOFPAC-NEXT: mov x0, x16
365 ; FPAC-LABEL: test_auth_trap_attribute:
367 ; FPAC-NEXT: mov x16, x0
368 ; FPAC-NEXT: autia x16, x1
369 ; FPAC-NEXT: mov x0, x16
371 %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1)
375 declare i64 @llvm.ptrauth.auth(i64, i32, i64)
376 declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64)