1 ; RUN: llc -mtriple=i386-linux < %s -o - | FileCheck --check-prefix=LINUX-I386 %s
2 ; RUN: llc -mtriple=x86_64-linux < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
3 ; RUN: llc -mtriple=i386-linux-android < %s -o - | FileCheck --check-prefix=ANDROID-I386 %s
4 ; RUN: llc -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefix=ANDROID-X64 %s
5 ; RUN: llc -mtriple=x86_64-fuchsia < %s -o - | FileCheck --check-prefix=FUCHSIA-X64 %s
7 ; RUN: llc -mtriple=i386-linux -safestack-use-pointer-address < %s -o - | FileCheck --check-prefix=LINUX-I386-PA %s
9 define void @_Z1fv() safestack {
11 %x = alloca i32, align 4
12 call void @_Z7CapturePi(ptr nonnull %x)
16 declare void @_Z7CapturePi(ptr)
18 ; LINUX-X64: movq __safestack_unsafe_stack_ptr@GOTTPOFF(%rip), %[[A:.*]]
19 ; LINUX-X64: movq %fs:(%[[A]]), %[[B:.*]]
20 ; LINUX-X64: leaq -16(%[[B]]), %[[C:.*]]
21 ; LINUX-X64: movq %[[C]], %fs:(%[[A]])
23 ; LINUX-I386: movl __safestack_unsafe_stack_ptr@INDNTPOFF, %[[A:.*]]
24 ; LINUX-I386: movl %gs:(%[[A]]), %[[B:.*]]
25 ; LINUX-I386: leal -16(%[[B]]), %[[C:.*]]
26 ; LINUX-I386: movl %[[C]], %gs:(%[[A]])
28 ; ANDROID-I386: movl %gs:36, %[[A:.*]]
29 ; ANDROID-I386: leal -16(%[[A]]), %[[B:.*]]
30 ; ANDROID-I386: movl %[[B]], %gs:36
32 ; ANDROID-X64: movq %fs:72, %[[A:.*]]
33 ; ANDROID-X64: leaq -16(%[[A]]), %[[B:.*]]
34 ; ANDROID-X64: movq %[[B]], %fs:72
36 ; FUCHSIA-X64: movq %fs:24, %[[A:.*]]
37 ; FUCHSIA-X64: leaq -16(%[[A]]), %[[B:.*]]
38 ; FUCHSIA-X64: movq %[[B]], %fs:24
40 ; LINUX-I386-PA: calll __safestack_pointer_address
41 ; LINUX-I386-PA: movl %eax, %[[A:.*]]
42 ; LINUX-I386-PA: movl (%eax), %[[B:.*]]
43 ; LINUX-I386-PA: leal -16(%[[B]]), %[[C:.*]]
44 ; LINUX-I386-PA: movl %[[C]], (%[[A]])