xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/fast-isel-stackcheck.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx"
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; selectiondag stack protector uses a GuardReg which the fast-isel stack
6*9880d681SAndroid Build Coastguard Worker; protection code did not but the state was not reset properly.
7*9880d681SAndroid Build Coastguard Worker; The optnone attribute on @bar forces fast-isel.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: foo:
10*9880d681SAndroid Build Coastguard Worker; CHECK: movq ___stack_chk_guard@GOTPCREL(%rip), %rax
11*9880d681SAndroid Build Coastguard Worker; CHECK: movq ___stack_chk_guard@GOTPCREL(%rip), %rax
12*9880d681SAndroid Build Coastguard Workerdefine void @foo() #0 {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker  %_tags = alloca [3 x i32], align 4
15*9880d681SAndroid Build Coastguard Worker  ret void
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: bar:
19*9880d681SAndroid Build Coastguard Worker; CHECK: movq ___stack_chk_guard@GOTPCREL(%rip), %{{r.x}}
20*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: movq ___stack_chk_guard@GOTPCREL(%rip), %[[GUARD:r.x]]
21*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: movq {{[0-9]+}}(%rsp), %[[CANARY:r.x]]
22*9880d681SAndroid Build Coastguard Worker; CHECK: subq %[[CANARY]], %[[GUARD]]
23*9880d681SAndroid Build Coastguard Workerdefine void @bar() #1 {
24*9880d681SAndroid Build Coastguard Workerentry:
25*9880d681SAndroid Build Coastguard Worker  %vt = alloca [2 x double], align 16
26*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %cleanup.4091, label %for.cond.3850
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerunreachable:
29*9880d681SAndroid Build Coastguard Worker  unreachable
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerfor.cond.3850:
32*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %land.rhs.3853, label %land.end.3857
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerland.rhs.3853:
35*9880d681SAndroid Build Coastguard Worker  br label %land.end.3857
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerland.end.3857:
38*9880d681SAndroid Build Coastguard Worker  %0 = phi i1 [ false, %for.cond.3850 ], [ false, %land.rhs.3853 ]
39*9880d681SAndroid Build Coastguard Worker  br i1 %0, label %unreachable, label %unreachable
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workercleanup.4091:
42*9880d681SAndroid Build Coastguard Worker  ret void
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerattributes #0 = { ssp }
46*9880d681SAndroid Build Coastguard Workerattributes #1 = { noinline optnone ssp }
47