[mlir] Update Ch-2.md (#121379)
[llvm-project.git] / llvm / test / CodeGen / AArch64 / sign-return-address-tailcall.ll
blob032d3cc05961f9b3ed9f278230d322bc99f6d77b
1 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 < %s | FileCheck -DAUTIASP="hint #29" --check-prefixes=COMMON %s
2 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=load                   < %s | FileCheck -DAUTIASP="hint #29" --check-prefixes=COMMON,LDR %s
3 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=high-bits-notbi        < %s | FileCheck -DAUTIASP="hint #29" --check-prefixes=COMMON,BITS-NOTBI,BRK %s
4 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac-hint              < %s | FileCheck -DAUTIASP="hint #29" -DXPACLRI="hint #7" --check-prefixes=COMMON,XPAC,BRK %s
5 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac-hint -mattr=v8.3a < %s | FileCheck -DAUTIASP="autiasp"  -DXPACLRI="xpaclri" --check-prefixes=COMMON,XPAC,BRK %s
6 ; RUN: llc -mtriple=aarch64 -asm-verbose=0 -aarch64-authenticated-lr-check-method=xpac      -mattr=v8.3a < %s | FileCheck -DAUTIASP="autiasp"  --check-prefixes=COMMON,XPAC83,BRK %s
8 define i32 @tailcall_direct() "sign-return-address"="non-leaf" {
9 ; COMMON-LABEL: tailcall_direct:
10 ; COMMON:         str x30, [sp, #-16]!
11 ; COMMON:         ldr x30, [sp], #16
13 ; COMMON-NEXT:    [[AUTIASP]]
15 ; LDR-NEXT:       ldr w16, [x30]
17 ; BITS-NOTBI-NEXT: eor x16, x30, x30, lsl #1
18 ; BITS-NOTBI-NEXT: tbz x16, #62, .[[GOOD:Lauth_success[_0-9]+]]
20 ; XPAC-NEXT:      mov x16, x30
21 ; XPAC-NEXT:      [[XPACLRI]]
22 ; XPAC-NEXT:      cmp x30, x16
23 ; XPAC-NEXT:      b.eq .[[GOOD:Lauth_success[_0-9]+]]
25 ; XPAC83-NEXT:    mov x16, x30
26 ; XPAC83-NEXT:    xpaci x16
27 ; XPAC83-NEXT:    cmp x30, x16
28 ; XPAC83-NEXT:    b.eq .[[GOOD:Lauth_success[_0-9]+]]
30 ; BRK-NEXT:       brk #0xc470
31 ; BRK-NEXT:     .[[GOOD]]:
32 ; COMMON-NEXT:    b callee
33   tail call void asm sideeffect "", "~{lr}"()
34   %call = tail call i32 @callee()
35   ret i32 %call
38 define i32 @tailcall_indirect(ptr %fptr) "sign-return-address"="non-leaf" {
39 ; COMMON-LABEL: tailcall_indirect:
40 ; COMMON:         str x30, [sp, #-16]!
41 ; COMMON:         ldr x30, [sp], #16
43 ; COMMON-NEXT:    [[AUTIASP]]
45 ; LDR-NEXT:       ldr w16, [x30]
47 ; BITS-NOTBI-NEXT: eor x16, x30, x30, lsl #1
48 ; BITS-NOTBI-NEXT: tbz x16, #62, .[[GOOD:Lauth_success[_0-9]+]]
50 ; XPAC-NEXT:      mov x16, x30
51 ; XPAC-NEXT:      [[XPACLRI]]
52 ; XPAC-NEXT:      cmp x30, x16
53 ; XPAC-NEXT:      b.eq .[[GOOD:Lauth_success[_0-9]+]]
55 ; XPAC83-NEXT:    mov x16, x30
56 ; XPAC83-NEXT:    xpaci x16
57 ; XPAC83-NEXT:    cmp x30, x16
58 ; XPAC83-NEXT:    b.eq .[[GOOD:Lauth_success[_0-9]+]]
60 ; BRK-NEXT:       brk #0xc470
61 ; BRK-NEXT:     .[[GOOD]]:
62 ; COMMON-NEXT:    br x0
63   tail call void asm sideeffect "", "~{lr}"()
64   %call = tail call i32 %fptr()
65   ret i32 %call
68 define i32 @tailcall_direct_noframe() "sign-return-address"="non-leaf" {
69 ; COMMON-LABEL: tailcall_direct_noframe:
70 ; COMMON-NEXT:    .cfi_startproc
71 ; COMMON-NEXT:    b callee
72   %call = tail call i32 @callee()
73   ret i32 %call
76 define i32 @tailcall_indirect_noframe(ptr %fptr) "sign-return-address"="non-leaf" {
77 ; COMMON-LABEL: tailcall_indirect_noframe:
78 ; COMMON-NEXT:    .cfi_startproc
79 ; COMMON-NEXT:    br x0
80   %call = tail call i32 %fptr()
81   ret i32 %call
84 define i32 @tailcall_direct_noframe_sign_all() "sign-return-address"="all" {
85 ; COMMON-LABEL: tailcall_direct_noframe_sign_all:
86 ; COMMON-NOT:     str{{.*}}x30
87 ; COMMON-NOT:     ldr{{.*}}x30
89 ; COMMON:         [[AUTIASP]]
91 ; LDR-NEXT:       ldr w16, [x30]
93 ; BITS-NOTBI-NEXT: eor x16, x30, x30, lsl #1
94 ; BITS-NOTBI-NEXT: tbz x16, #62, .[[GOOD:Lauth_success[_0-9]+]]
96 ; XPAC-NEXT:      mov x16, x30
97 ; XPAC-NEXT:      [[XPACLRI]]
98 ; XPAC-NEXT:      cmp x30, x16
99 ; XPAC-NEXT:      b.eq .[[GOOD:Lauth_success[_0-9]+]]
101 ; XPAC83-NEXT:    mov x16, x30
102 ; XPAC83-NEXT:    xpaci x16
103 ; XPAC83-NEXT:    cmp x30, x16
104 ; XPAC83-NEXT:    b.eq .[[GOOD:Lauth_success[_0-9]+]]
106 ; BRK-NEXT:       brk #0xc470
107 ; BRK-NEXT:     .[[GOOD]]:
108 ; COMMON-NEXT:    b callee
109   %call = tail call i32 @callee()
110   ret i32 %call
113 define i32 @tailcall_indirect_noframe_sign_all(ptr %fptr) "sign-return-address"="all" {
114 ; COMMON-LABEL: tailcall_indirect_noframe_sign_all:
115 ; COMMON-NOT:     str{{.*}}x30
116 ; COMMON-NOT:     ldr{{.*}}x30
118 ; COMMON:         [[AUTIASP]]
120 ; LDR-NEXT:       ldr w16, [x30]
122 ; BITS-NOTBI-NEXT: eor x16, x30, x30, lsl #1
123 ; BITS-NOTBI-NEXT: tbz x16, #62, .[[GOOD:Lauth_success[_0-9]+]]
125 ; XPAC-NEXT:      mov x16, x30
126 ; XPAC-NEXT:      [[XPACLRI]]
127 ; XPAC-NEXT:      cmp x30, x16
128 ; XPAC-NEXT:      b.eq .[[GOOD:Lauth_success[_0-9]+]]
130 ; XPAC83-NEXT:    mov x16, x30
131 ; XPAC83-NEXT:    xpaci x16
132 ; XPAC83-NEXT:    cmp x30, x16
133 ; XPAC83-NEXT:    b.eq .[[GOOD:Lauth_success[_0-9]+]]
135 ; BRK-NEXT:       brk #0xc470
136 ; BRK-NEXT:     .[[GOOD]]:
137 ; COMMON-NEXT:    br x0
138   %call = tail call i32 %fptr()
139   ret i32 %call
142 define i32 @tailcall_ib_key() "sign-return-address"="all" "sign-return-address-key"="b_key" {
143 ; COMMON-LABEL: tailcall_ib_key:
145 ; BRK:            brk #0xc471
146 ; BRK-NEXT:     .{{Lauth_success.*}}:
147 ; COMMON:         b callee
148   tail call void asm sideeffect "", "~{lr}"()
149   %call = tail call i32 @callee()
150   ret i32 %call
153 define i32 @tailcall_two_branches(i1 %0) "sign-return-address"="all" {
154 ; COMMON-LABEL:    tailcall_two_branches:
155 ; COMMON:            tbz w0, #0, .[[ELSE:LBB[_0-9]+]]
156 ; COMMON:            str x30, [sp, #-16]!
157 ; COMMON:            bl callee2
158 ; COMMON:            ldr x30, [sp], #16
159 ; COMMON-NEXT:       [[AUTIASP]]
160 ; COMMON-NEXT:     .[[ELSE]]:
162 ; LDR-NEXT:          ldr w16, [x30]
164 ; BITS-NOTBI-NEXT:   eor x16, x30, x30, lsl #1
165 ; BITS-NOTBI-NEXT:   tbz x16, #62, .[[GOOD:Lauth_success[_0-9]+]]
167 ; XPAC-NEXT:         mov x16, x30
168 ; XPAC-NEXT:         [[XPACLRI]]
169 ; XPAC-NEXT:         cmp x30, x16
170 ; XPAC-NEXT:         b.eq .[[GOOD:Lauth_success[_0-9]+]]
172 ; XPAC83-NEXT:       mov x16, x30
173 ; XPAC83-NEXT:       xpaci x16
174 ; XPAC83-NEXT:       cmp x30, x16
175 ; XPAC83-NEXT:       b.eq .[[GOOD:Lauth_success[_0-9]+]]
177 ; BRK-NEXT:          brk #0xc470
178 ; BRK-NEXT:        .[[GOOD]]:
179 ; COMMON-NEXT:       b callee
180   br i1 %0, label %2, label %3
182   call void @callee2()
183   br label %3
185   %call = tail call i32 @callee()
186   ret i32 %call
189 declare i32 @callee()
190 declare void @callee2()