1 # RUN: llc -o - -run-pass=machine-scheduler -misched=shuffle %s | FileCheck %s
2 # RUN: llc -o - -run-pass=postmisched %s | FileCheck %s
5 # -misched=shuffle is only available with assertions enabled
7 # Check that instructions that are recognized as branch targets by BTI
8 # are not reordered by machine instruction schedulers.
11 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
12 target triple = "aarch64-unknown-linux-gnu"
14 define i32 @f_pac_pseudo(i32 %a, i32 %b, i32 %c) #0 "sign-return-address"="all" {
19 define i32 @f_pac(i32 %a, i32 %b, i32 %c) #0 "sign-return-address"="all" {
24 define i32 @f_bti(i32 %a, i32 %b, i32 %c) #0 {
29 define i32 @f_brk(i32 %a, i32 %b, i32 %c) #0 {
34 define i32 @f_hlt(i32 %a, i32 %b, i32 %c) #0 {
39 define i32 @f_nop(i32 %a, i32 %b, i32 %c) #0 {
44 attributes #0 = { nounwind memory(none) "target-features"="+v8.2a" }
50 tracksRegLiveness: true
53 liveins: $w0, $w1, $w2, $lr
55 frame-setup PAUTH_PROLOGUE implicit-def $lr, implicit $lr, implicit $sp
56 $w8 = ADDWrs $w0, $w1, 0
57 $w0 = MADDWrrr $w8, $w2, $wzr
58 RET undef $lr, implicit $w0
60 # PAUTH_EPILOGUE instruction is omitted for simplicity as it is technically possible
61 # to move it, so it may end up at a less obvious position in a basic block.
63 # CHECK-LABEL: name: f_pac_pseudo
65 # CHECK-NEXT: bb.0.entry:
66 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
68 # CHECK: frame-setup PAUTH_PROLOGUE implicit-def $lr, implicit {{.*}}$lr, implicit $sp
69 # CHECK-NEXT: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
70 # CHECK-NEXT: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
71 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0
77 tracksRegLiveness: true
80 liveins: $w0, $w1, $w2, $lr
82 frame-setup PACIASP implicit-def $lr, implicit $lr, implicit $sp
83 $w8 = ADDWrs $w0, $w1, 0
84 $w0 = MADDWrrr $w8, $w2, $wzr
85 RET undef $lr, implicit $w0
87 # AUTIASP is omitted, see above.
89 # CHECK-LABEL: name: f_pac
91 # CHECK-NEXT: bb.0.entry:
92 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
94 # CHECK: frame-setup PACIASP implicit-def $lr, implicit {{.*}}$lr, implicit $sp
95 # CHECK-NEXT: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
96 # CHECK-NEXT: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
97 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0
103 tracksRegLiveness: true
106 liveins: $w0, $w1, $w2, $lr
109 $w8 = ADDWrs $w0, $w1, 0
110 $w0 = MADDWrrr $w8, $w2, $wzr
111 RET undef $lr, implicit $w0
113 # CHECK-LABEL: name: f_bti
115 # CHECK-NEXT: bb.0.entry:
116 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
119 # CHECK-NEXT: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
120 # CHECK-NEXT: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
121 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0
127 tracksRegLiveness: true
130 liveins: $w0, $w1, $w2, $lr
133 $w8 = ADDWrs $w0, $w1, 0
134 $w0 = MADDWrrr $w8, $w2, $wzr
135 RET undef $lr, implicit $w0
137 # CHECK-LABEL: name: f_brk
139 # CHECK-NEXT: bb.0.entry:
140 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
143 # CHECK-NEXT: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
144 # CHECK-NEXT: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
145 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0
151 tracksRegLiveness: true
154 liveins: $w0, $w1, $w2, $lr
157 $w8 = ADDWrs $w0, $w1, 0
158 $w0 = MADDWrrr $w8, $w2, $wzr
159 RET undef $lr, implicit $w0
161 # CHECK-LABEL: name: f_hlt
163 # CHECK-NEXT: bb.0.entry:
164 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
167 # CHECK-NEXT: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
168 # CHECK-NEXT: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
169 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0
175 tracksRegLiveness: true
178 liveins: $w0, $w1, $w2, $lr
181 $w8 = ADDWrs $w0, $w1, 0
182 $w0 = MADDWrrr $w8, $w2, $wzr
183 RET undef $lr, implicit $w0
185 # Check that BTI-related instructions are left intact not because *anything*
188 # CHECK-LABEL: name: f_nop
190 # CHECK-NEXT: bb.0.entry:
191 # CHECK-NEXT: liveins: $w0, $w1, $w2, $lr
193 # CHECK: $w8 = ADDWrs {{.*}}$w0, {{.*}}$w1, 0
194 # CHECK-DAG: $w0 = MADDWrrr {{.*}}$w8, {{.*}}$w2, $wzr
196 # CHECK-NEXT: RET undef $lr, implicit {{.*}}$w0