• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
3
4define void @f(i1 %d1, i1 %d2) safestack {
5entry:
6; CHECK-LABEL: define void @f(
7; CHECK:         %[[USP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr
8; CHECK-NEXT:    getelementptr i8, i8* %[[USP]], i32 -16
9; CHECK:         br i1 %d1, label %[[BB0:.*]], label %[[BB1:.*]]
10  %a = alloca i32, align 8
11  %b = alloca i32, align 8
12  br i1 %d1, label %bb0, label %bb1
13
14bb0:
15; CHECK: [[BB0]]:
16; CHECK: %[[Ai8:.*]] = getelementptr i8, i8* %unsafe_stack_ptr, i32
17; CHECK: %[[AUNSAFE:.*]] = bitcast i8* %[[Ai8]] to i32*
18; CHECK: br i1
19  br i1 %d2, label %bb2, label %bb2
20
21bb1:
22; CHECK: [[BB1]]:
23; CHECK: %[[Bi8:.*]] = getelementptr i8, i8* %unsafe_stack_ptr, i32
24; CHECK: %[[BUNSAFE:.*]] = bitcast i8* %[[Bi8]] to i32*
25; CHECK: br label
26  br label %bb2
27
28bb2:
29; CHECK: phi i32* [ %[[AUNSAFE]], %[[BB0]] ], [ %[[AUNSAFE]], %[[BB0]] ], [ %[[BUNSAFE]], %[[BB1]] ]
30  %c = phi i32* [ %a, %bb0 ], [ %a, %bb0 ], [ %b, %bb1 ]
31  call void @capture(i32* %c)
32  ret void
33}
34
35declare void @capture(i32*)
36