1 ; RUN: opt -safe-stack -S -mtriple=aarch64-linux-android < %s -o - | FileCheck --check-prefixes=TLS,ANDROID %s
2 ; RUN: opt -safe-stack -S -mtriple=aarch64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=TLS,FUCHSIA %s
4 define void @foo() nounwind uwtable safestack sspreq {
6 ; The first @llvm.thread.pointer is for the unsafe stack pointer, skip it.
7 ; TLS: call i8* @llvm.thread.pointer()
9 ; TLS: %[[TP2:.*]] = call i8* @llvm.thread.pointer()
10 ; ANDROID: %[[B:.*]] = getelementptr i8, i8* %[[TP2]], i32 40
11 ; FUCHSIA: %[[B:.*]] = getelementptr i8, i8* %[[TP2]], i32 -16
12 ; TLS: %[[C:.*]] = bitcast i8* %[[B]] to i8**
13 ; TLS: %[[StackGuard:.*]] = load i8*, i8** %[[C]]
14 ; TLS: store i8* %[[StackGuard]], i8** %[[StackGuardSlot:.*]]
15 %a = alloca i128, align 16
16 call void @Capture(i128* %a)
18 ; TLS: %[[A:.*]] = load i8*, i8** %[[StackGuardSlot]]
19 ; TLS: icmp ne i8* %[[StackGuard]], %[[A]]
23 declare void @Capture(i128*)