[LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)
[llvm-project.git] / llvm / test / CodeGen / AArch64 / ptrauth-fpac.ll
blobd5340dcebad5758969a4a57a66422c2bed376535
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:
11 ; ALL:       %bb.0:
12 ; ALL-NEXT:    mov x16, x0
13 ; ALL-NEXT:    autia x16, x1
14 ; ALL-NEXT:    mov x0, x16
15 ; ALL-NEXT:    ret
16   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1)
17   ret i64 %tmp
20 define i64 @test_auth_ia_zero(i64 %arg) {
21 ; ALL-LABEL: test_auth_ia_zero:
22 ; ALL:       %bb.0:
23 ; ALL-NEXT:    mov x16, x0
24 ; ALL-NEXT:    autiza x16
25 ; ALL-NEXT:    mov x0, x16
26 ; ALL-NEXT:    ret
27   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 0)
28   ret i64 %tmp
31 define i64 @test_auth_ib(i64 %arg, i64 %arg1) {
32 ; ALL-LABEL: test_auth_ib:
33 ; ALL:       %bb.0:
34 ; ALL-NEXT:    mov x16, x0
35 ; ALL-NEXT:    autib x16, x1
36 ; ALL-NEXT:    mov x0, x16
37 ; ALL-NEXT:    ret
38   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 %arg1)
39   ret i64 %tmp
42 define i64 @test_auth_ib_zero(i64 %arg) {
43 ; ALL-LABEL: test_auth_ib_zero:
44 ; ALL:       %bb.0:
45 ; ALL-NEXT:    mov x16, x0
46 ; ALL-NEXT:    autizb x16
47 ; ALL-NEXT:    mov x0, x16
48 ; ALL-NEXT:    ret
49   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 1, i64 0)
50   ret i64 %tmp
53 define i64 @test_auth_da(i64 %arg, i64 %arg1) {
54 ; ALL-LABEL: test_auth_da:
55 ; ALL:       %bb.0:
56 ; ALL-NEXT:    mov x16, x0
57 ; ALL-NEXT:    autda x16, x1
58 ; ALL-NEXT:    mov x0, x16
59 ; ALL-NEXT:    ret
60   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 %arg1)
61   ret i64 %tmp
64 define i64 @test_auth_da_zero(i64 %arg) {
65 ; ALL-LABEL: test_auth_da_zero:
66 ; ALL:       %bb.0:
67 ; ALL-NEXT:    mov x16, x0
68 ; ALL-NEXT:    autdza x16
69 ; ALL-NEXT:    mov x0, x16
70 ; ALL-NEXT:    ret
71   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 2, i64 0)
72   ret i64 %tmp
75 define i64 @test_auth_db(i64 %arg, i64 %arg1) {
76 ; ALL-LABEL: test_auth_db:
77 ; ALL:       %bb.0:
78 ; ALL-NEXT:    mov x16, x0
79 ; ALL-NEXT:    autdb x16, x1
80 ; ALL-NEXT:    mov x0, x16
81 ; ALL-NEXT:    ret
82   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 %arg1)
83   ret i64 %tmp
86 define i64 @test_auth_db_zero(i64 %arg) {
87 ; ALL-LABEL: test_auth_db_zero:
88 ; ALL:       %bb.0:
89 ; ALL-NEXT:    mov x16, x0
90 ; ALL-NEXT:    autdzb x16
91 ; ALL-NEXT:    mov x0, x16
92 ; ALL-NEXT:    ret
93   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 3, i64 0)
94   ret i64 %tmp
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:
101 ; NOFPAC:       %bb.0:
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
114 ; NOFPAC-NEXT:    ret
116 ; FPAC-LABEL: test_resign_ia_ia:
117 ; FPAC:       %bb.0:
118 ; FPAC-NEXT:    mov x16, x0
119 ; FPAC-NEXT:    autia x16, x1
120 ; FPAC-NEXT:    pacia x16, x2
121 ; FPAC-NEXT:    mov x0, x16
122 ; FPAC-NEXT:    ret
123   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 %arg1, i32 0, i64 %arg2)
124   ret i64 %tmp
127 define i64 @test_resign_ib_ia(i64 %arg, i64 %arg1, i64 %arg2) {
128 ; NOFPAC-LABEL: test_resign_ib_ia:
129 ; NOFPAC:       %bb.0:
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
142 ; NOFPAC-NEXT:    ret
144 ; FPAC-LABEL: test_resign_ib_ia:
145 ; FPAC:       %bb.0:
146 ; FPAC-NEXT:    mov x16, x0
147 ; FPAC-NEXT:    autib x16, x1
148 ; FPAC-NEXT:    pacia x16, x2
149 ; FPAC-NEXT:    mov x0, x16
150 ; FPAC-NEXT:    ret
151   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 1, i64 %arg1, i32 0, i64 %arg2)
152   ret i64 %tmp
155 define i64 @test_resign_da_ia(i64 %arg, i64 %arg1, i64 %arg2) {
156 ; NOFPAC-LABEL: test_resign_da_ia:
157 ; NOFPAC:       %bb.0:
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
170 ; NOFPAC-NEXT:    ret
172 ; FPAC-LABEL: test_resign_da_ia:
173 ; FPAC:       %bb.0:
174 ; FPAC-NEXT:    mov x16, x0
175 ; FPAC-NEXT:    autda x16, x1
176 ; FPAC-NEXT:    pacia x16, x2
177 ; FPAC-NEXT:    mov x0, x16
178 ; FPAC-NEXT:    ret
179   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 0, i64 %arg2)
180   ret i64 %tmp
183 define i64 @test_resign_db_ia(i64 %arg, i64 %arg1, i64 %arg2) {
184 ; NOFPAC-LABEL: test_resign_db_ia:
185 ; NOFPAC:       %bb.0:
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
198 ; NOFPAC-NEXT:    ret
200 ; FPAC-LABEL: test_resign_db_ia:
201 ; FPAC:       %bb.0:
202 ; FPAC-NEXT:    mov x16, x0
203 ; FPAC-NEXT:    autdb x16, x1
204 ; FPAC-NEXT:    pacia x16, x2
205 ; FPAC-NEXT:    mov x0, x16
206 ; FPAC-NEXT:    ret
207   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 0, i64 %arg2)
208   ret i64 %tmp
211 define i64 @test_resign_db_ib(i64 %arg, i64 %arg1, i64 %arg2) {
212 ; NOFPAC-LABEL: test_resign_db_ib:
213 ; NOFPAC:       %bb.0:
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
226 ; NOFPAC-NEXT:    ret
228 ; FPAC-LABEL: test_resign_db_ib:
229 ; FPAC:       %bb.0:
230 ; FPAC-NEXT:    mov x16, x0
231 ; FPAC-NEXT:    autdb x16, x1
232 ; FPAC-NEXT:    pacib x16, x2
233 ; FPAC-NEXT:    mov x0, x16
234 ; FPAC-NEXT:    ret
235   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 1, i64 %arg2)
236   ret i64 %tmp
239 define i64 @test_resign_db_da(i64 %arg, i64 %arg1, i64 %arg2) {
240 ; NOFPAC-LABEL: test_resign_db_da:
241 ; NOFPAC:       %bb.0:
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
254 ; NOFPAC-NEXT:    ret
256 ; FPAC-LABEL: test_resign_db_da:
257 ; FPAC:       %bb.0:
258 ; FPAC-NEXT:    mov x16, x0
259 ; FPAC-NEXT:    autdb x16, x1
260 ; FPAC-NEXT:    pacda x16, x2
261 ; FPAC-NEXT:    mov x0, x16
262 ; FPAC-NEXT:    ret
263   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 2, i64 %arg2)
264   ret i64 %tmp
267 define i64 @test_resign_db_db(i64 %arg, i64 %arg1, i64 %arg2) {
268 ; NOFPAC-LABEL: test_resign_db_db:
269 ; NOFPAC:       %bb.0:
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
282 ; NOFPAC-NEXT:    ret
284 ; FPAC-LABEL: test_resign_db_db:
285 ; FPAC:       %bb.0:
286 ; FPAC-NEXT:    mov x16, x0
287 ; FPAC-NEXT:    autdb x16, x1
288 ; FPAC-NEXT:    pacdb x16, x2
289 ; FPAC-NEXT:    mov x0, x16
290 ; FPAC-NEXT:    ret
291   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 3, i64 %arg1, i32 3, i64 %arg2)
292   ret i64 %tmp
295 define i64 @test_resign_iza_db(i64 %arg, i64 %arg1, i64 %arg2) {
296 ; NOFPAC-LABEL: test_resign_iza_db:
297 ; NOFPAC:       %bb.0:
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
310 ; NOFPAC-NEXT:    ret
312 ; FPAC-LABEL: test_resign_iza_db:
313 ; FPAC:       %bb.0:
314 ; FPAC-NEXT:    mov x16, x0
315 ; FPAC-NEXT:    autiza x16
316 ; FPAC-NEXT:    pacdb x16, x2
317 ; FPAC-NEXT:    mov x0, x16
318 ; FPAC-NEXT:    ret
319   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 0, i64 0, i32 3, i64 %arg2)
320   ret i64 %tmp
323 define i64 @test_resign_da_dzb(i64 %arg, i64 %arg1, i64 %arg2) {
324 ; NOFPAC-LABEL: test_resign_da_dzb:
325 ; NOFPAC:       %bb.0:
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
338 ; NOFPAC-NEXT:    ret
340 ; FPAC-LABEL: test_resign_da_dzb:
341 ; FPAC:       %bb.0:
342 ; FPAC-NEXT:    mov x16, x0
343 ; FPAC-NEXT:    autda x16, x1
344 ; FPAC-NEXT:    pacdzb x16
345 ; FPAC-NEXT:    mov x0, x16
346 ; FPAC-NEXT:    ret
347   %tmp = call i64 @llvm.ptrauth.resign(i64 %arg, i32 2, i64 %arg1, i32 3, i64 0)
348   ret i64 %tmp
351 define i64 @test_auth_trap_attribute(i64 %arg, i64 %arg1) "ptrauth-auth-traps" {
352 ; NOFPAC-LABEL: test_auth_trap_attribute:
353 ; NOFPAC:       %bb.0:
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
363 ; NOFPAC-NEXT:    ret
365 ; FPAC-LABEL: test_auth_trap_attribute:
366 ; FPAC:       %bb.0:
367 ; FPAC-NEXT:    mov x16, x0
368 ; FPAC-NEXT:    autia x16, x1
369 ; FPAC-NEXT:    mov x0, x16
370 ; FPAC-NEXT:    ret
371   %tmp = call i64 @llvm.ptrauth.auth(i64 %arg, i32 0, i64 %arg1)
372   ret i64 %tmp
375 declare i64 @llvm.ptrauth.auth(i64, i32, i64)
376 declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64)