1 ; RUN: llc -mtriple=arm64-apple-macosx -fast-isel %s -o - -start-before=stack-protector -stop-after=stack-protector | FileCheck %s
3 @var = global [2 x i64]* null
7 define void @caller1() ssp {
8 ; CHECK-LABEL: define void @caller1()
10 ; CHECK: @llvm.stackguard
12 ; CHECK: [[GUARD:%.*]] = call i8* @llvm.stackguard()
13 ; CHECK: [[TOKEN:%.*]] = load volatile i8*, i8** {{%.*}}
14 ; CHECK: [[TST:%.*]] = icmp eq i8* [[GUARD]], [[TOKEN]]
15 ; CHECK: br i1 [[TST]]
17 ; CHECK: musttail call void @callee()
18 ; CHECK-NEXT: ret void
19 %var = alloca [2 x i64]
20 store [2 x i64]* %var, [2 x i64]** @var
21 musttail call void @callee()
25 define void @justret() ssp {
26 ; CHECK-LABEL: define void @justret()
28 ; CHECK: @llvm.stackguard
30 ; CHECK: [[GUARD:%.*]] = call i8* @llvm.stackguard()
31 ; CHECK: [[TOKEN:%.*]] = load volatile i8*, i8** {{%.*}}
32 ; CHECK: [[TST:%.*]] = icmp eq i8* [[GUARD]], [[TOKEN]]
33 ; CHECK: br i1 [[TST]]
36 %var = alloca [2 x i64]
37 store [2 x i64]* %var, [2 x i64]** @var
45 declare i64* @callee2()
47 define i8* @caller2() ssp {
48 ; CHECK-LABEL: define i8* @caller2()
50 ; CHECK: @llvm.stackguard
52 ; CHECK: [[GUARD:%.*]] = call i8* @llvm.stackguard()
53 ; CHECK: [[TOKEN:%.*]] = load volatile i8*, i8** {{%.*}}
54 ; CHECK: [[TST:%.*]] = icmp eq i8* [[GUARD]], [[TOKEN]]
55 ; CHECK: br i1 [[TST]]
57 ; CHECK: [[TMP:%.*]] = musttail call i64* @callee2()
58 ; CHECK-NEXT: [[RES:%.*]] = bitcast i64* [[TMP]] to i8*
59 ; CHECK-NEXT: ret i8* [[RES]]
61 %var = alloca [2 x i64]
62 store [2 x i64]* %var, [2 x i64]** @var
63 %tmp = musttail call i64* @callee2()
64 %res = bitcast i64* %tmp to i8*