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
3 ; RUN: opt -passes=safe-stack -safe-stack-coloring=1 -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
5 define void @f() safestack {
6 ; CHECK-LABEL: define void @f
8 ; CHECK: %[[USP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
9 ; CHECK: getelementptr i8, ptr %[[USP]], i32 -16
11 %x0 = alloca i64, align 8
12 %x1 = alloca i8, align 1
13 %x2 = alloca i64, align 8
16 call void @llvm.lifetime.start.p0(i64 8, ptr %x0)
17 call void @capture64(ptr %x0)
18 call void @llvm.lifetime.end.p0(i64 8, ptr %x0)
20 call void @llvm.lifetime.start.p0(i64 1, ptr %x1)
21 call void @llvm.lifetime.start.p0(i64 8, ptr %x2)
22 call void @capture8(ptr %x1)
23 call void @capture64(ptr %x2)
24 call void @llvm.lifetime.end.p0(i64 1, ptr %x1)
25 call void @llvm.lifetime.end.p0(i64 8, ptr %x2)
27 ; Test that i64 allocas share space.
28 ; CHECK: getelementptr i8, ptr %unsafe_stack_ptr, i32 -8
29 ; CHECK: getelementptr i8, ptr %unsafe_stack_ptr, i32 -9
30 ; CHECK: getelementptr i8, ptr %unsafe_stack_ptr, i32 -8
35 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
36 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
37 declare void @capture8(ptr)
38 declare void @capture64(ptr)