blob: 4d13d98441e0d1a76d543e274a644ba21d7021a5 [file] [log] [blame]
Kristof Beylse66bc1f2018-12-18 08:50:02 +00001; RUN: sed -e 's/SLHATTR/speculative_load_hardening/' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,SLH --dump-input-on-failure
2; RUN: sed -e 's/SLHATTR//' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,NOSLH --dump-input-on-failure
3
4declare i64 @g(i64, i64) local_unnamed_addr
5define i64 @f_using_reserved_reg_x16(i64 %a, i64 %b) local_unnamed_addr SLHATTR {
6; CHECK-LABEL: f_using_reserved_reg_x16
7; SLH: dsb sy
8; SLH: isb
9; NOSLH-NOT: dsb sy
10; NOSLH-NOT: isb
11entry:
12 %cmp = icmp ugt i64 %a, %b
13 br i1 %cmp, label %if.then, label %cleanup
14
15; CHECK: b.ls
16; SLH: dsb sy
17; SLH: isb
18; NOSLH-NOT: dsb sy
19; NOSLH-NOT: isb
20if.then:
21 %0 = tail call i64 asm "autia1716", "={x17},{x16},0"(i64 %b, i64 %a)
22; CHECK: bl g
23; SLH: dsb sy
24; SLH: isb
25; NOSLH-NOT: dsb sy
26; NOSLH-NOT: isb
27; CHECK: ret
28 %call = tail call i64 @g(i64 %a, i64 %b) #3
29 %add = add i64 %call, %0
30 br label %cleanup
31
32cleanup:
33; SLH: dsb sy
34; SLH: isb
35; NOSLH-NOT: dsb sy
36; NOSLH-NOT: isb
37; SLH: ret
38 %retval.0 = phi i64 [ %add, %if.then ], [ %b, %entry ]
39 ret i64 %retval.0
40}
41
42define i32 @f_clobbered_reg_w16(i32 %a, i32 %b) local_unnamed_addr SLHATTR {
43; CHECK-LABEL: f_clobbered_reg_w16
44entry:
45; SLH: dsb sy
46; SLH: isb
47; NOSLH-NOT: dsb sy
48; NOSLH-NOT: isb
49 %cmp = icmp sgt i32 %a, %b
50 br i1 %cmp, label %if.then, label %if.end
51; CHECK: b.le
52
53if.then:
54; SLH: dsb sy
55; SLH: isb
56; NOSLH-NOT: dsb sy
57; NOSLH-NOT: isb
58; CHECK: mov w16, w0
59 tail call void asm sideeffect "mov w16, ${0:w}", "r,~{w16}"(i32 %a)
60 br label %if.end
61; SLH: ret
62
63if.end:
64 %add = add nsw i32 %b, %a
65 ret i32 %add
66; SLH: dsb sy
67; SLH: isb
68; NOSLH-NOT: dsb sy
69; NOSLH-NOT: isb
70; SLH: ret
71}