summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-01-23 21:27:07 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-01-23 21:27:07 +0000
commitd5a6fdbe95943f63d6b003a4d883437d7645ff46 (patch)
treeb31b76a6b29d48881fd96999593ba29e852c8e40 /llvm/test/CodeGen/X86
parentc1e2290d373b461f71744ad0792e8306a66f0dee (diff)
downloadbcm5719-llvm-d5a6fdbe95943f63d6b003a4d883437d7645ff46.tar.gz
bcm5719-llvm-d5a6fdbe95943f63d6b003a4d883437d7645ff46.zip
[safestack] Inline safestack pointer access when possible.
Summary: This adds an -mllvm flag that forces the use of a runtime function call to get the unsafe stack pointer, the same that is currently used on non-x86, non-aarch64 android. The call may be inlined. Reviewers: pcc Subscribers: aemerson, kristof.beyls, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D37405 llvm-svn: 323259
Diffstat (limited to 'llvm/test/CodeGen/X86')
-rw-r--r--llvm/test/CodeGen/X86/safestack.ll8
-rw-r--r--llvm/test/CodeGen/X86/safestack_inline.ll30
2 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/safestack.ll b/llvm/test/CodeGen/X86/safestack.ll
index bd8f57f5e3c..a9d1b32cfcf 100644
--- a/llvm/test/CodeGen/X86/safestack.ll
+++ b/llvm/test/CodeGen/X86/safestack.ll
@@ -4,6 +4,8 @@
; RUN: llc -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefix=ANDROID-X64 %s
; RUN: llc -mtriple=x86_64-fuchsia < %s -o - | FileCheck --check-prefix=FUCHSIA-X64 %s
+; RUN: llc -mtriple=i386-linux -safestack-use-pointer-address < %s -o - | FileCheck --check-prefix=LINUX-I386-PA %s
+
define void @_Z1fv() safestack {
entry:
%x = alloca i32, align 4
@@ -35,3 +37,9 @@ declare void @_Z7CapturePi(i32*)
; FUCHSIA-X64: movq %fs:24, %[[A:.*]]
; FUCHSIA-X64: leaq -16(%[[A]]), %[[B:.*]]
; FUCHSIA-X64: movq %[[B]], %fs:24
+
+; LINUX-I386-PA: calll __safestack_pointer_address
+; LINUX-I386-PA: movl %eax, %[[A:.*]]
+; LINUX-I386-PA: movl (%[[A]]), %[[B:.*]]
+; LINUX-I386-PA: leal -16(%[[B]]), %[[C:.*]]
+; LINUX-I386-PA: movl %[[C]], (%[[A]])
diff --git a/llvm/test/CodeGen/X86/safestack_inline.ll b/llvm/test/CodeGen/X86/safestack_inline.ll
new file mode 100644
index 00000000000..ed93c498564
--- /dev/null
+++ b/llvm/test/CodeGen/X86/safestack_inline.ll
@@ -0,0 +1,30 @@
+; RUN: sed -e "s/ATTR//" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=INLINE %s
+; RUN: sed -e "s/ATTR/noinline/" %s | llc -mtriple=x86_64-linux -safestack-use-pointer-address | FileCheck --check-prefix=CALL %s
+
+@p = external thread_local global i8*, align 8
+
+define nonnull i8** @__safestack_pointer_address() local_unnamed_addr ATTR {
+entry:
+ ret i8** @p
+}
+
+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*)
+
+; INLINE: movq p@GOTTPOFF(%rip), %[[A:.*]]
+; INLINE: movq %fs:(%[[A]]), %[[B:.*]]
+; INLINE: leaq -16(%[[B]]), %[[C:.*]]
+; INLINE: movq %[[C]], %fs:(%[[A]])
+
+; CALL: callq __safestack_pointer_address
+; CALL: movq %rax, %[[A:.*]]
+; CALL: movq (%[[A]]), %[[B:.*]]
+; CALL: leaq -16(%[[B]]), %[[C:.*]]
+; CALL: movq %[[C]], (%[[A]])
OpenPOWER on IntegriCloud