Protection against stack-based memory corruption errors using SafeStack
[oota-llvm.git] / test / Transforms / SafeStack / constant-geps.ll
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
4 %struct.deep = type { %union.anon }
5 %union.anon = type { %struct.anon }
6 %struct.anon = type { %struct.anon.0 }
7 %struct.anon.0 = type { %union.anon.1 }
8 %union.anon.1 = type { [2 x i8] }
9
10 @.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
11
12 ; [2 x i8] nested in several layers of structs and unions
13 ;  safestack attribute
14 ; Requires no protector.
15 ; CHECK-LABEL: @foo(
16 define signext i8 @foo() nounwind uwtable safestack {
17 entry:
18   ; CHECK-NOT: __safestack_unsafe_stack_ptr
19   %x = alloca %struct.deep, align 1
20   %b = getelementptr inbounds %struct.deep, %struct.deep* %x, i32 0, i32 0
21   %c = bitcast %union.anon* %b to %struct.anon*
22   %d = getelementptr inbounds %struct.anon, %struct.anon* %c, i32 0, i32 0
23   %e = getelementptr inbounds %struct.anon.0, %struct.anon.0* %d, i32 0, i32 0
24   %array = bitcast %union.anon.1* %e to [2 x i8]*
25   %arrayidx = getelementptr inbounds [2 x i8], [2 x i8]* %array, i32 0, i64 0
26   %0 = load i8, i8* %arrayidx, align 1
27   ret i8 %0
28 }