• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4define void @f() safestack {
5; CHECK-LABEL: define void @f
6entry:
7; CHECK:  %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
8; CHECK:   getelementptr i8, i8* %[[USP]], i32 -16
9
10  %x0 = alloca i64, align 8
11  %x1 = alloca i8, align 1
12  %x2 = alloca i64, align 8
13
14  %x0a = bitcast i64* %x0 to i8*
15  %x2a = bitcast i64* %x2 to i8*
16
17  call void @llvm.lifetime.start.p0i8(i64 8, i8* %x0a)
18  call void @capture64(i64* %x0)
19  call void @llvm.lifetime.end.p0i8(i64 8, i8* %x0a)
20
21  call void @llvm.lifetime.start.p0i8(i64 1, i8* %x1)
22  call void @llvm.lifetime.start.p0i8(i64 8, i8* %x2a)
23  call void @capture8(i8* %x1)
24  call void @capture64(i64* %x2)
25  call void @llvm.lifetime.end.p0i8(i64 1, i8* %x1)
26  call void @llvm.lifetime.end.p0i8(i64 8, i8* %x2a)
27
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
32
33  ret void
34}
35
36declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
37declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
38declare void @capture8(i8*)
39declare void @capture64(i64*)
40