xref: /llvm-project/llvm/test/CodeGen/X86/safestack_inline.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
1; RUN: sed -e "s/ATTR//" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=INLINE %s
2; RUN: sed -e "s/ATTR/noinline/" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=CALL %s
3
4@p = external thread_local global ptr, align 8
5
6define nonnull ptr @__safestack_pointer_address() local_unnamed_addr ATTR {
7entry:
8  ret ptr @p
9}
10
11define void @_Z1fv() safestack {
12entry:
13  %x = alloca i32, align 4
14  call void @_Z7CapturePi(ptr nonnull %x)
15  ret void
16}
17
18declare void @_Z7CapturePi(ptr)
19
20; INLINE: movq p@GOTTPOFF(%rip), %[[A:.*]]
21; INLINE: movq %fs:(%[[A]]), %[[B:.*]]
22; INLINE: leaq -16(%[[B]]), %[[C:.*]]
23; INLINE: movq %[[C]], %fs:(%[[A]])
24
25; CALL: callq __safestack_pointer_address
26; CALL: movq %rax, %[[A:.*]]
27; CALL: movq (%rax), %[[B:.*]]
28; CALL: leaq -16(%[[B]]), %[[C:.*]]
29; CALL: movq %[[C]], (%[[A]])
30