xref: /llvm-project/llvm/test/Transforms/SafeStack/X86/coloring-ssp.ll (revision 3bd517205799a152689434ceddf9493765f1e883)
1; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
2; RUN: opt -passes=safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
3
4; %x and %y share a stack slot between them, but not with the stack guard.
5define void @f() safestack sspreq {
6; CHECK-LABEL: define void @f
7entry:
8; CHECK:  %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
9; CHECK:   getelementptr i8, ptr %[[USP]], i32 -16
10
11; CHECK:  %[[A:.*]] = getelementptr i8, ptr %[[USP]], i32 -8
12; CHECK:  store ptr %{{.*}}, ptr %[[A]]
13
14  %x = alloca i64, align 8
15  %y = alloca i64, align 8
16
17  call void @llvm.lifetime.start.p0(i64 -1, ptr %x)
18; CHECK:  getelementptr i8, ptr %[[USP]], i32 -16
19  call void @capture64(ptr %x)
20  call void @llvm.lifetime.end.p0(i64 -1, ptr %x)
21
22  call void @llvm.lifetime.start.p0(i64 -1, ptr %y)
23; CHECK:  getelementptr i8, ptr %[[USP]], i32 -16
24  call void @capture64(ptr %y)
25  call void @llvm.lifetime.end.p0(i64 -1, ptr %y)
26
27  ret void
28}
29
30declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
31declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
32declare void @capture64(ptr)
33