1; RUN: opt -safe-stack -S -mtriple=i686-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
2; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
3
4; RUN: opt -safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,GLOBAL32 %s
5; RUN: opt -safe-stack -S -mtriple=i686-linux-android24 < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
6
7; RUN: opt -safe-stack -S -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
8
9; RUN: opt -safe-stack -S -mtriple=x86_64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=COMMON,FUCHSIA64 %s
10
11define void @foo() safestack sspreq {
12entry:
13; TLS32: %[[StackGuard:.*]] = load i8*, i8* addrspace(256)* inttoptr (i32 20 to i8* addrspace(256)*)
14; TLS64: %[[StackGuard:.*]] = load i8*, i8* addrspace(257)* inttoptr (i32 40 to i8* addrspace(257)*)
15; FUCHSIA64: %[[StackGuard:.*]] = load i8*, i8* addrspace(257)* inttoptr (i32 16 to i8* addrspace(257)*)
16; GLOBAL32: %[[StackGuard:.*]] = load i8*, i8** @__stack_chk_guard
17; COMMON:   store i8* %[[StackGuard]], i8** %[[StackGuardSlot:.*]]
18  %a = alloca i8, align 1
19  call void @Capture(i8* %a)
20
21; COMMON: %[[A:.*]] = load i8*, i8** %[[StackGuardSlot]]
22; COMMON: icmp ne i8* %[[StackGuard]], %[[A]]
23  ret void
24}
25
26declare void @Capture(i8*)
27