Skip to content

Commit 30e11d2

Browse files
committed
[test][PAC][AArch64] Add ELF tests for subtarget-neutral codegen
1 parent 8ac6b41 commit 30e11d2

File tree

5 files changed

+212
-129
lines changed

5 files changed

+212
-129
lines changed

llvm/test/CodeGen/AArch64/ptrauth-bti-call.ll

Lines changed: 75 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,128 @@
1-
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -asm-verbose=false -o - %s | FileCheck %s
2-
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -global-isel -asm-verbose=false -o - %s | FileCheck %s
3-
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -fast-isel -asm-verbose=false -o - %s | FileCheck %s
1+
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -asm-verbose=false \
2+
; RUN: -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
3+
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -global-isel -asm-verbose=false \
4+
; RUN: -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
5+
; RUN: llc -mtriple arm64e-apple-darwin -mattr=+bti -fast-isel -asm-verbose=false \
6+
; RUN: -o - %s | FileCheck %s --check-prefixes=DARWIN,CHECK
7+
; RUN: llc -mtriple aarch64-linux-gnu -mattr=+bti -mattr=+pauth -asm-verbose=false \
8+
; RUN: -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
9+
; RUN: llc -mtriple aarch64-linux-gnu -mattr=+bti -mattr=+pauth -global-isel -asm-verbose=false \
10+
; RUN: -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
11+
; RUN: llc -mtriple aarch64-linux-gnu -mattr=+bti -mattr=+pauth -fast-isel -asm-verbose=false \
12+
; RUN: -o - %s | FileCheck %s --check-prefixes=ELF,CHECK
413

5-
; ptrauth tail-calls can only use x16/x17 with BTI.
14+
;; ptrauth tail-calls can only use x16/x17 with BTI.
615

7-
; CHECK-LABEL: _test_tailcall_ia_0:
8-
; CHECK-NEXT: bti c
9-
; CHECK-NEXT: mov x16, x0
10-
; CHECK-NEXT: braaz x16
16+
; DARWIN-LABEL: _test_tailcall_ia_0:
17+
; ELF-LABEL: test_tailcall_ia_0:
18+
; CHECK-NEXT: bti c
19+
; CHECK-NEXT: mov x16, x0
20+
; CHECK-NEXT: braaz x16
1121
define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 {
1222
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ]
1323
ret i32 %tmp0
1424
}
1525

16-
; CHECK-LABEL: _test_tailcall_ib_0:
17-
; CHECK-NEXT: bti c
18-
; CHECK-NEXT: mov x16, x0
19-
; CHECK-NEXT: brabz x16
26+
; DARWIN-LABEL: _test_tailcall_ib_0:
27+
; ELF-LABEL: test_tailcall_ib_0:
28+
; CHECK-NEXT: bti c
29+
; CHECK-NEXT: mov x16, x0
30+
; CHECK-NEXT: brabz x16
2031
define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 {
2132
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ]
2233
ret i32 %tmp0
2334
}
2435

25-
; CHECK-LABEL: _test_tailcall_ia_imm:
26-
; CHECK-NEXT: bti c
27-
; CHECK-NEXT: mov x16, x0
28-
; CHECK-NEXT: mov x17, #42
29-
; CHECK-NEXT: braa x16, x17
36+
; DARWIN-LABEL: _test_tailcall_ia_imm:
37+
; ELF-LABEL: test_tailcall_ia_imm:
38+
; CHECK-NEXT: bti c
39+
; CHECK-NEXT: mov x16, x0
40+
; CHECK-NEXT: mov x17, #42
41+
; CHECK-NEXT: braa x16, x17
3042
define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 {
3143
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ]
3244
ret i32 %tmp0
3345
}
3446

35-
; CHECK-LABEL: _test_tailcall_ib_imm:
36-
; CHECK-NEXT: bti c
37-
; CHECK-NEXT: mov x16, x0
38-
; CHECK-NEXT: mov x17, #42
39-
; CHECK-NEXT: brab x16, x17
47+
; DARWIN-LABEL: _test_tailcall_ib_imm:
48+
; ELF-LABEL: test_tailcall_ib_imm:
49+
; CHECK-NEXT: bti c
50+
; CHECK-NEXT: mov x16, x0
51+
; CHECK-NEXT: mov x17, #42
52+
; CHECK-NEXT: brab x16, x17
4053
define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 {
4154
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ]
4255
ret i32 %tmp0
4356
}
4457

45-
; CHECK-LABEL: _test_tailcall_ia_var:
46-
; CHECK-NEXT: bti c
47-
; CHECK-NEXT: mov x16, x0
48-
; CHECK-NEXT: ldr x0, [x1]
49-
; CHECK-NEXT: braa x16, x0
58+
; DARWIN-LABEL: _test_tailcall_ia_var:
59+
; DARWIN-NEXT: bti c
60+
; DARWIN-NEXT: mov x16, x0
61+
; DARWIN-NEXT: ldr x0, [x1]
62+
; DARWIN-NEXT: braa x16, x0
63+
; ELF-LABEL: test_tailcall_ia_var:
64+
; ELF-NEXT: bti c
65+
; ELF-NEXT: ldr x1, [x1]
66+
; ELF-NEXT: mov x16, x0
67+
; ELF-NEXT: braa x16, x1
5068
define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 {
5169
%tmp0 = load i64, i64* %arg1
5270
%tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ]
5371
ret i32 %tmp1
5472
}
5573

56-
; CHECK-LABEL: _test_tailcall_ib_var:
57-
; CHECK-NEXT: bti c
58-
; CHECK-NEXT: mov x16, x0
59-
; CHECK-NEXT: ldr x0, [x1]
60-
; CHECK-NEXT: brab x16, x0
74+
; DARWIN-LABEL: _test_tailcall_ib_var:
75+
; DARWIN-NEXT: bti c
76+
; DARWIN-NEXT: mov x16, x0
77+
; DARWIN-NEXT: ldr x0, [x1]
78+
; DARWIN-NEXT: brab x16, x0
79+
; ELF-LABEL: test_tailcall_ib_var:
80+
; ELF-NEXT: bti c
81+
; ELF-NEXT: ldr x1, [x1]
82+
; ELF-NEXT: mov x16, x0
83+
; ELF-NEXT: brab x16, x1
6184
define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 {
6285
%tmp0 = load i64, i64* %arg1
6386
%tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ]
6487
ret i32 %tmp1
6588
}
6689

67-
; CHECK-LABEL: _test_tailcall_ia_arg:
68-
; CHECK-NEXT: bti c
69-
; CHECK-NEXT: mov x16, x0
70-
; CHECK-NEXT: braa x16, x1
90+
; DARWIN-LABEL: _test_tailcall_ia_arg:
91+
; ELF-LABEL: test_tailcall_ia_arg:
92+
; CHECK-NEXT: bti c
93+
; CHECK-NEXT: mov x16, x0
94+
; CHECK-NEXT: braa x16, x1
7195
define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 {
7296
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ]
7397
ret i32 %tmp0
7498
}
7599

76-
; CHECK-LABEL: _test_tailcall_ib_arg:
77-
; CHECK-NEXT: bti c
78-
; CHECK-NEXT: mov x16, x0
79-
; CHECK-NEXT: brab x16, x1
100+
; DARWIN-LABEL: _test_tailcall_ib_arg:
101+
; ELF-LABEL: test_tailcall_ib_arg:
102+
; CHECK-NEXT: bti c
103+
; CHECK-NEXT: mov x16, x0
104+
; CHECK-NEXT: brab x16, x1
80105
define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 {
81106
%tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ]
82107
ret i32 %tmp0
83108
}
84109

85-
; CHECK-LABEL: _test_tailcall_ia_arg_ind:
86-
; CHECK-NEXT: bti c
87-
; CHECK-NEXT: ldr x16, [x0]
88-
; CHECK-NEXT: braa x16, x1
110+
; DARWIN-LABEL: _test_tailcall_ia_arg_ind:
111+
; ELF-LABEL: test_tailcall_ia_arg_ind:
112+
; CHECK-NEXT: bti c
113+
; CHECK-NEXT: ldr x16, [x0]
114+
; CHECK-NEXT: braa x16, x1
89115
define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
90116
%tmp0 = load i32 ()*, i32 ()** %arg0
91117
%tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ]
92118
ret i32 %tmp1
93119
}
94120

95-
; CHECK-LABEL: _test_tailcall_ib_arg_ind:
96-
; CHECK-NEXT: bti c
97-
; CHECK-NEXT: ldr x16, [x0]
98-
; CHECK-NEXT: brab x16, x1
121+
; DARWIN-LABEL: _test_tailcall_ib_arg_ind:
122+
; ELF-LABEL: test_tailcall_ib_arg_ind:
123+
; CHECK-NEXT: bti c
124+
; CHECK-NEXT: ldr x16, [x0]
125+
; CHECK-NEXT: brab x16, x1
99126
define i32 @test_tailcall_ib_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
100127
%tmp0 = load i32 ()*, i32 ()** %arg0
101128
%tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ]

llvm/test/CodeGen/AArch64/ptrauth-intrinsic-blend.ll

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,58 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
3-
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
2+
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs \
3+
; RUN: -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
4+
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs \
5+
; RUN: -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
6+
; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
7+
; RUN: -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
8+
; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
9+
; RUN: -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
410

511
define i64 @test_blend(i64 %arg, i64 %arg1) {
6-
; CHECK-LABEL: test_blend:
7-
; CHECK: ; %bb.0:
8-
; CHECK-NEXT: bfi x0, x1, #48, #16
9-
; CHECK-NEXT: ret
12+
; DARWIN-LABEL: _test_blend:
13+
; ELF-LABEL: test_blend:
14+
; DARWIN: ; %bb.0:
15+
; ELF: // %bb.0:
16+
; CHECK-NEXT: bfi x0, x1, #48, #16
17+
; CHECK-NEXT: ret
1018
%tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 %arg1)
1119
ret i64 %tmp
1220
}
1321

1422
define i64 @test_blend_constant(i64 %arg) {
15-
; CHECK-LABEL: test_blend_constant:
16-
; CHECK: ; %bb.0:
17-
; CHECK-NEXT: movk x0, #12345, lsl #48
18-
; CHECK-NEXT: ret
23+
; DARWIN-LABEL: _test_blend_constant:
24+
; ELF-LABEL: test_blend_constant:
25+
; DARWIN: ; %bb.0:
26+
; ELF: // %bb.0:
27+
; CHECK-NEXT: movk x0, #12345, lsl #48
28+
; CHECK-NEXT: ret
1929
%tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 12345)
2030
ret i64 %tmp
2131
}
2232

2333
; Blend isn't commutative.
2434
define i64 @test_blend_constant_swapped(i64 %arg) {
25-
; CHECK-LABEL: test_blend_constant_swapped:
26-
; CHECK: ; %bb.0:
27-
; CHECK-NEXT: mov w8, #12345
28-
; CHECK-NEXT: bfi x8, x0, #48, #16
29-
; CHECK-NEXT: mov x0, x8
30-
; CHECK-NEXT: ret
35+
; DARWIN-LABEL: _test_blend_constant_swapped:
36+
; ELF-LABEL: test_blend_constant_swapped:
37+
; DARWIN: ; %bb.0:
38+
; ELF: // %bb.0:
39+
; CHECK-NEXT: mov w8, #12345
40+
; CHECK-NEXT: bfi x8, x0, #48, #16
41+
; CHECK-NEXT: mov x0, x8
42+
; CHECK-NEXT: ret
3143
%tmp = call i64 @llvm.ptrauth.blend(i64 12345, i64 %arg)
3244
ret i64 %tmp
3345
}
3446

3547
; Blends of constants wider than 16 bits truncate the constant.
3648
define i64 @test_blend_constant_wide(i64 %arg) {
37-
; CHECK-LABEL: test_blend_constant_wide:
38-
; CHECK: ; %bb.0:
39-
; CHECK-NEXT: mov w8, #65536
40-
; CHECK-NEXT: bfi x0, x8, #48, #16
41-
; CHECK-NEXT: ret
49+
; DARWIN-LABEL: _test_blend_constant_wide:
50+
; ELF-LABEL: test_blend_constant_wide:
51+
; DARWIN: ; %bb.0:
52+
; ELF: // %bb.0:
53+
; CHECK-NEXT: mov w8, #65536
54+
; CHECK-NEXT: bfi x0, x8, #48, #16
55+
; CHECK-NEXT: ret
4256
%tmp = call i64 @llvm.ptrauth.blend(i64 %arg, i64 65536)
4357
ret i64 %tmp
4458
}

llvm/test/CodeGen/AArch64/ptrauth-intrinsic-sign-generic.ll

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=0 | FileCheck %s
3-
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs -global-isel=1 -global-isel-abort=1 | FileCheck %s
2+
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs \
3+
; RUN: -global-isel=0 | FileCheck %s --check-prefixes=DARWIN,CHECK
4+
; RUN: llc < %s -mtriple arm64e-apple-darwin -verify-machineinstrs \
5+
; RUN: -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=DARWIN,CHECK
6+
; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
7+
; RUN: -global-isel=0 | FileCheck %s --check-prefixes=ELF,CHECK
8+
; RUN: llc < %s -mtriple aarch64-linux-gnu -mattr=+pauth -verify-machineinstrs \
9+
; RUN: -global-isel=1 -global-isel-abort=1 | FileCheck %s --check-prefixes=ELF,CHECK
410

511
define i64 @test_sign_generic(i64 %arg, i64 %arg1) {
6-
; CHECK-LABEL: test_sign_generic:
7-
; CHECK: ; %bb.0:
8-
; CHECK-NEXT: pacga x0, x0, x1
9-
; CHECK-NEXT: ret
12+
; DARWIN-LABEL: _test_sign_generic:
13+
; ELF-LABEL: test_sign_generic:
14+
; DARWIN: ; %bb.0:
15+
; ELF: // %bb.0:
16+
; CHECK-NEXT: pacga x0, x0, x1
17+
; CHECK-NEXT: ret
1018
%tmp = call i64 @llvm.ptrauth.sign.generic(i64 %arg, i64 %arg1)
1119
ret i64 %tmp
1220
}

0 commit comments

Comments
 (0)