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
4 define void @f() safestack {
6 ; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
7 ; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
9 %x = alloca i32, align 4
10 %x1 = alloca i32, align 4
11 %x2 = alloca i32, align 4
12 %0 = bitcast i32* %x to i8*
13 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
15 ; CHECK: %[[A1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
16 ; CHECK: %[[A2:.*]] = bitcast i8* %[[A1]] to i32*
17 ; CHECK: call void @capture(i32* nonnull %[[A2]])
19 call void @capture(i32* nonnull %x)
20 call void @llvm.lifetime.end.p0i8(i64 4, i8* %0)
21 %1 = bitcast i32* %x1 to i8*
22 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1)
24 ; CHECK: %[[B1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
25 ; CHECK: %[[B2:.*]] = bitcast i8* %[[B1]] to i32*
26 ; CHECK: call void @capture(i32* nonnull %[[B2]])
28 call void @capture(i32* nonnull %x1)
29 call void @llvm.lifetime.end.p0i8(i64 4, i8* %1)
30 %2 = bitcast i32* %x2 to i8*
31 call void @llvm.lifetime.start.p0i8(i64 4, i8* %2)
33 ; CHECK: %[[C1:.*]] = getelementptr i8, i8* %[[USP]], i32 -4
34 ; CHECK: %[[C2:.*]] = bitcast i8* %[[C1]] to i32*
35 ; CHECK: call void @capture(i32* nonnull %[[C2]])
37 call void @capture(i32* nonnull %x2)
38 call void @llvm.lifetime.end.p0i8(i64 4, i8* %2)
42 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
43 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
44 declare void @capture(i32*)