1 ; RUN: sed -e 's/SLHATTR/speculative_load_hardening/' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu | FileCheck %s --check-prefixes=CHECK,SLH,NOGISELSLH --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,NOGISELNOSLH --dump-input-on-failure
3 ; RUN: sed -e 's/SLHATTR/speculative_load_hardening/' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -global-isel | FileCheck %s --check-prefixes=CHECK,SLH,GISELSLH --dump-input-on-failure
4 ; RUN sed -e 's/SLHATTR//' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -global-isel | FileCheck %s --check-prefixes=CHECK,NOSLH,GISELNOSLH --dump-input-on-failure
5 ; RUN: sed -e 's/SLHATTR/speculative_load_hardening/' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -fast-isel | FileCheck %s --check-prefixes=CHECK,SLH,NOGISELSLH --dump-input-on-failure
6 ; RUN: sed -e 's/SLHATTR//' %s | llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -fast-isel | FileCheck %s --check-prefixes=CHECK,NOSLH,NOGISELNOSLH --dump-input-on-failure
8 define i32 @f(i8* nocapture readonly %p, i32 %i, i32 %N) local_unnamed_addr SLHATTR {
13 ; NOSLH-NOT: cmp sp, #0
14 ; NOSLH-NOT: csetm x16, ne
16 ; SLH: mov [[TMPREG:x[0-9]+]], sp
17 ; SLH: and [[TMPREG]], [[TMPREG]], x16
18 ; SLH: mov sp, [[TMPREG]]
19 ; NOSLH-NOT: mov [[TMPREG:x[0-9]+]], sp
20 ; NOSLH-NOT: and [[TMPREG]], [[TMPREG]], x16
21 ; NOSLH-NOT: mov sp, [[TMPREG]]
22 %call = tail call i32 @tail_callee(i32 %i)
25 ; NOSLH-NOT: cmp sp, #0
26 ; NOSLH-NOT: csetm x16, ne
27 %cmp = icmp slt i32 %call, %N
28 br i1 %cmp, label %if.then, label %return
29 ; GlobalISel lowers the branch to a b.ne sometimes instead of b.ge as expected..
30 ; CHECK: b.[[COND:(ge)|(lt)|(ne)]]
32 if.then: ; preds = %entry
33 ; NOSLH-NOT: csel x16, x16, xzr, {{(lt)|(ge)|(eq)}}
34 ; SLH-DAG: csel x16, x16, xzr, {{(lt)|(ge)|(eq)}}
35 %idxprom = sext i32 %i to i64
36 %arrayidx = getelementptr inbounds i8, i8* %p, i64 %idxprom
37 %0 = load i8, i8* %arrayidx, align 1
38 ; CHECK-DAG: ldrb [[LOADED:w[0-9]+]],
39 %conv = zext i8 %0 to i32
42 ; SLH-DAG: csel x16, x16, xzr, [[COND]]
43 ; NOSLH-NOT: csel x16, x16, xzr, [[COND]]
44 return: ; preds = %entry, %if.then
45 %retval.0 = phi i32 [ %conv, %if.then ], [ 0, %entry ]
46 ; SLH: mov [[TMPREG:x[0-9]+]], sp
47 ; SLH: and [[TMPREG]], [[TMPREG]], x16
48 ; SLH: mov sp, [[TMPREG]]
49 ; NOSLH-NOT: mov [[TMPREG:x[0-9]+]], sp
50 ; NOSLH-NOT: and [[TMPREG]], [[TMPREG]], x16
51 ; NOSLH-NOT: mov sp, [[TMPREG]]
55 ; Make sure that for a tail call, taint doesn't get put into SP twice.
56 define i32 @tail_caller(i32 %a) local_unnamed_addr SLHATTR {
57 ; CHECK-LABEL: tail_caller:
58 ; NOGISELSLH: mov [[TMPREG:x[0-9]+]], sp
59 ; NOGISELSLH: and [[TMPREG]], [[TMPREG]], x16
60 ; NOGISELSLH: mov sp, [[TMPREG]]
61 ; NOGISELNOSLH-NOT: mov [[TMPREG:x[0-9]+]], sp
62 ; NOGISELNOSLH-NOT: and [[TMPREG]], [[TMPREG]], x16
63 ; NOGISELNOSLH-NOT: mov sp, [[TMPREG]]
64 ; GISELSLH: mov [[TMPREG:x[0-9]+]], sp
65 ; GISELSLH: and [[TMPREG]], [[TMPREG]], x16
66 ; GISELSLH: mov sp, [[TMPREG]]
67 ; GISELNOSLH-NOT: mov [[TMPREG:x[0-9]+]], sp
68 ; GISELNOSLH-NOT: and [[TMPREG]], [[TMPREG]], x16
69 ; GISELNOSLH-NOT: mov sp, [[TMPREG]]
70 ; GlobalISel doesn't optimize tail calls (yet?), so only check that
71 ; cross-call taint register setup code is missing if a tail call was
73 ; NOGISELSLH: b tail_callee
74 ; GISELSLH: bl tail_callee
75 ; GISELSLH: cmp sp, #0
77 %call = tail call i32 @tail_callee(i32 %a)
81 declare i32 @tail_callee(i32) local_unnamed_addr
83 ; Verify that no cb(n)z/tb(n)z instructions are produced when implementing
85 define i32 @compare_branch_zero(i32, i32) SLHATTR {
86 ; CHECK-LABEL: compare_branch_zero
87 %3 = icmp eq i32 %0, 0
88 br i1 %3, label %then, label %else
99 define i32 @test_branch_zero(i32, i32) SLHATTR {
100 ; CHECK-LABEL: test_branch_zero
102 %4 = icmp eq i32 %3, 0
103 br i1 %4, label %then, label %else
114 define i32 @landingpad(i32 %l0, i32 %l1) SLHATTR personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
115 ; CHECK-LABEL: landingpad
119 ; NOSLH-NOT: cmp sp, #0
120 ; NOSLH-NOT: csetm x16, ne
121 ; CHECK: bl _Z10throwing_fv
122 invoke void @_Z10throwing_fv()
123 to label %exit unwind label %lpad
128 %l4 = landingpad { i8*, i32 }
132 ; NOSLH-NOT: cmp sp, #0
133 ; NOSLH-NOT: csetm x16, ne
134 %l5 = extractvalue { i8*, i32 } %l4, 0
135 %l6 = tail call i8* @__cxa_begin_catch(i8* %l5)
136 %l7 = icmp sgt i32 %l0, %l1
137 br i1 %l7, label %then, label %else
138 ; GlobalISel lowers the branch to a b.ne sometimes instead of b.ge as expected..
139 ; CHECK: b.[[COND:(le)|(gt)|(ne)]]
142 ; SLH-DAG: csel x16, x16, xzr, [[COND]]
143 %l9 = sdiv i32 %l0, %l1
147 ; SLH-DAG: csel x16, x16, xzr, {{(gt)|(le)|(eq)}}
148 %l11 = sdiv i32 %l1, %l0
152 %l13 = phi i32 [ %l9, %then ], [ %l11, %else ]
153 tail call void @__cxa_end_catch()
157 %l15 = phi i32 [ %l13, %postif ], [ 0, %entry ]
161 declare i32 @__gxx_personality_v0(...)
162 declare void @_Z10throwing_fv() local_unnamed_addr
163 declare i8* @__cxa_begin_catch(i8*) local_unnamed_addr
164 declare void @__cxa_end_catch() local_unnamed_addr