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
14 ; ptrauth tail-calls can only use x16/x17 with BTI.
16 ; CHECK-LABEL: test_tailcall_ia_0:
18 ; CHECK-NEXT: mov x16, x0
19 ; CHECK-NEXT: braaz x16
20 define i32 @test_tailcall_ia_0(i32 ()* %arg0) #0 {
21 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 0) ]
25 ; CHECK-LABEL: test_tailcall_ib_0:
27 ; CHECK-NEXT: mov x16, x0
28 ; CHECK-NEXT: brabz x16
29 define i32 @test_tailcall_ib_0(i32 ()* %arg0) #0 {
30 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 0) ]
34 ; CHECK-LABEL: test_tailcall_ia_imm:
36 ; CHECK-NEXT: mov x16, x0
37 ; CHECK-NEXT: mov x17, #42
38 ; CHECK-NEXT: braa x16, x17
39 define i32 @test_tailcall_ia_imm(i32 ()* %arg0) #0 {
40 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 42) ]
44 ; CHECK-LABEL: test_tailcall_ib_imm:
46 ; CHECK-NEXT: mov x16, x0
47 ; CHECK-NEXT: mov x17, #42
48 ; CHECK-NEXT: brab x16, x17
49 define i32 @test_tailcall_ib_imm(i32 ()* %arg0) #0 {
50 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 42) ]
54 ; CHECK-LABEL: test_tailcall_ia_var:
56 ; DARWIN-NEXT: mov x16, x0
57 ; DARWIN-NEXT: ldr x0, [x1]
58 ; DARWIN-NEXT: braa x16, x0
60 ; ELF-NEXT: ldr x1, [x1]
61 ; ELF-NEXT: mov x16, x0
62 ; ELF-NEXT: braa x16, x1
63 define i32 @test_tailcall_ia_var(i32 ()* %arg0, i64* %arg1) #0 {
64 %tmp0 = load i64, i64* %arg1
65 %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %tmp0) ]
69 ; CHECK-LABEL: test_tailcall_ib_var:
71 ; DARWIN-NEXT: mov x16, x0
72 ; DARWIN-NEXT: ldr x0, [x1]
73 ; DARWIN-NEXT: brab x16, x0
75 ; ELF-NEXT: ldr x1, [x1]
76 ; ELF-NEXT: mov x16, x0
77 ; ELF-NEXT: brab x16, x1
78 define i32 @test_tailcall_ib_var(i32 ()* %arg0, i64* %arg1) #0 {
79 %tmp0 = load i64, i64* %arg1
80 %tmp1 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %tmp0) ]
84 ; CHECK-LABEL: test_tailcall_ia_arg:
86 ; CHECK-NEXT: mov x16, x0
87 ; CHECK-NEXT: braa x16, x1
88 define i32 @test_tailcall_ia_arg(i32 ()* %arg0, i64 %arg1) #0 {
89 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 0, i64 %arg1) ]
93 ; CHECK-LABEL: test_tailcall_ib_arg:
95 ; CHECK-NEXT: mov x16, x0
96 ; CHECK-NEXT: brab x16, x1
97 define i32 @test_tailcall_ib_arg(i32 ()* %arg0, i64 %arg1) #0 {
98 %tmp0 = tail call i32 %arg0() [ "ptrauth"(i32 1, i64 %arg1) ]
102 ; CHECK-LABEL: test_tailcall_ia_arg_ind:
104 ; CHECK-NEXT: ldr x16, [x0]
105 ; CHECK-NEXT: braa x16, x1
106 define i32 @test_tailcall_ia_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
107 %tmp0 = load i32 ()*, i32 ()** %arg0
108 %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 0, i64 %arg1) ]
112 ; CHECK-LABEL: test_tailcall_ib_arg_ind:
114 ; CHECK-NEXT: ldr x16, [x0]
115 ; CHECK-NEXT: brab x16, x1
116 define i32 @test_tailcall_ib_arg_ind(i32 ()** %arg0, i64 %arg1) #0 {
117 %tmp0 = load i32 ()*, i32 ()** %arg0
118 %tmp1 = tail call i32 %tmp0() [ "ptrauth"(i32 1, i64 %arg1) ]
122 attributes #0 = { nounwind "branch-target-enforcement"="true" }