1 ; Test that safestack layout reuses a region w/o fragmentation.
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 {
5 ; CHECK-LABEL: define void @f
7 ; CHECK: %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
8 ; CHECK: getelementptr i8, i8* %[[USP]], i32 -16
10 %x0 = alloca i64, align 8
11 %x1 = alloca i8, align 1
12 %x2 = alloca i64, align 8
14 %x0a = bitcast i64* %x0 to i8*
15 %x2a = bitcast i64* %x2 to i8*
17 call void @llvm.lifetime.start.p0i8(i64 4, i8* %x0a)
18 call void @capture64(i64* %x0)
19 call void @llvm.lifetime.end.p0i8(i64 4, i8* %x0a)
21 call void @llvm.lifetime.start.p0i8(i64 4, i8* %x1)
22 call void @llvm.lifetime.start.p0i8(i64 4, i8* %x2a)
23 call void @capture8(i8* %x1)
24 call void @capture64(i64* %x2)
25 call void @llvm.lifetime.end.p0i8(i64 4, i8* %x1)
26 call void @llvm.lifetime.end.p0i8(i64 4, i8* %x2a)
28 ; Test that i64 allocas share space.
29 ; CHECK: getelementptr i8, i8* %unsafe_stack_ptr, i32 -8
30 ; CHECK: getelementptr i8, i8* %unsafe_stack_ptr, i32 -9
31 ; CHECK: getelementptr i8, i8* %unsafe_stack_ptr, i32 -8
36 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
37 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
38 declare void @capture8(i8*)
39 declare void @capture64(i64*)