aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/safestack.ll
blob: 1ff9a050aefbde0385ea6e2cb41b7fc12a5953ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
; RUN: llc -mtriple=i386-linux < %s -o - | FileCheck --check-prefix=LINUX-I386 %s
; RUN: llc -mtriple=x86_64-linux < %s -o - | FileCheck --check-prefix=LINUX-X64 %s
; RUN: llc -mtriple=i386-linux-android < %s -o - | FileCheck --check-prefix=ANDROID-I386 %s
; RUN: llc -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefix=ANDROID-X64 %s

define void @_Z1fv() safestack {
entry:
  %x = alloca i32, align 4
  %0 = bitcast i32* %x to i8*
  call void @_Z7CapturePi(i32* nonnull %x)
  ret void
}

declare void @_Z7CapturePi(i32*)

; LINUX-X64: movq __safestack_unsafe_stack_ptr@GOTTPOFF(%rip), %[[A:.*]]
; LINUX-X64: movq %fs:(%[[A]]), %[[B:.*]]
; LINUX-X64: leaq -16(%[[B]]), %[[C:.*]]
; LINUX-X64: movq %[[C]], %fs:(%[[A]])

; LINUX-I386: movl __safestack_unsafe_stack_ptr@INDNTPOFF, %[[A:.*]]
; LINUX-I386: movl %gs:(%[[A]]), %[[B:.*]]
; LINUX-I386: leal -16(%[[B]]), %[[C:.*]]
; LINUX-I386: movl %[[C]], %gs:(%[[A]])

; ANDROID-I386: movl %gs:36, %[[A:.*]]
; ANDROID-I386: leal -16(%[[A]]), %[[B:.*]]
; ANDROID-I386: movl %[[B]], %gs:36

; ANDROID-X64: movq %fs:72, %[[A:.*]]
; ANDROID-X64: leaq -16(%[[A]]), %[[B:.*]]
; ANDROID-X64: movq %[[B]], %fs:72