xref: /llvm-project/llvm/test/Transforms/SafeStack/X86/coloring.ll (revision 3bd517205799a152689434ceddf9493765f1e883)
1; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2; RUN: opt -safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
3; RUN: opt -passes=safe-stack -safe-stack-coloring=1 -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
4; RUN: opt -passes=safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
5
6define void @f() safestack {
7entry:
8; CHECK:  %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
9; CHECK:  %[[USST:.*]] = getelementptr i8, ptr %[[USP]], i32 -16
10
11  %x = alloca i32, align 4
12  %x1 = alloca i32, align 4
13  %x2 = alloca i32, align 4
14  call void @llvm.lifetime.start.p0(i64 4, ptr %x)
15
16; CHECK:  %[[A1:.*]] = getelementptr i8, ptr %[[USP]], i32 -4
17; CHECK:  call void @capture(ptr nonnull %[[A1]])
18
19  call void @capture(ptr nonnull %x)
20  call void @llvm.lifetime.end.p0(i64 4, ptr %x)
21  call void @llvm.lifetime.start.p0(i64 4, ptr %x1)
22
23; CHECK:  %[[B1:.*]] = getelementptr i8, ptr %[[USP]], i32 -4
24; CHECK:  call void @capture(ptr nonnull %[[B1]])
25
26  call void @capture(ptr nonnull %x1)
27  call void @llvm.lifetime.end.p0(i64 4, ptr %x1)
28  call void @llvm.lifetime.start.p0(i64 4, ptr %x2)
29
30; CHECK:  %[[C1:.*]] = getelementptr i8, ptr %[[USP]], i32 -4
31; CHECK:  call void @capture(ptr nonnull %[[C1]])
32
33  call void @capture(ptr nonnull %x2)
34  call void @llvm.lifetime.end.p0(i64 4, ptr %x2)
35  ret void
36}
37
38declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
39declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
40declare void @capture(ptr)
41