[PATCH] D40856: [X86][Darwin] Add Darwin stack probing functions

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 14:32:01 PST 2017


aemerson created this revision.
Herald added subscribers: Sanitizers, mgorny.

[X86][Darwin] Add Darwin stack probing functions.

The new function is a clone of an existing implementation, and doesn't modify the stack pointer.

rdar://25859140


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D40856

Files:
  lib/builtins/CMakeLists.txt
  lib/builtins/x86_64/chkstk_darwin.S


Index: lib/builtins/x86_64/chkstk_darwin.S
===================================================================
--- /dev/null
+++ lib/builtins/x86_64/chkstk_darwin.S
@@ -0,0 +1,32 @@
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+
+#include "../assembly.h"
+
+#ifdef __x86_64__ 
+
+#define PAGE_SZ 4096
+
+// ___chkstk_darwin is at the moment implemented the same way as ms version.         
+DEFINE_COMPILERRT_FUNCTION(___chkstk_darwin)
+.weak_definition ___chkstk_darwin
+        push   %rcx
+        push   %rax
+        cmp    $PAGE_SZ,%rax
+        lea    24(%rsp),%rcx
+        jb     1f
+2:
+        sub    $PAGE_SZ,%rcx
+        test   %rcx,(%rcx)
+        sub    $PAGE_SZ,%rax
+        cmp    $PAGE_SZ,%rax
+        ja     2b
+1:
+        sub    %rax,%rcx
+        test   %rcx,(%rcx)
+        pop    %rax
+        pop    %rcx
+        ret
+END_COMPILERRT_FUNCTION(___chkstk_darwin)
+
+#endif // __x86_64__
Index: lib/builtins/CMakeLists.txt
===================================================================
--- lib/builtins/CMakeLists.txt
+++ lib/builtins/CMakeLists.txt
@@ -234,6 +234,7 @@
   set(x86_64_SOURCES
       x86_64/chkstk.S
       x86_64/chkstk2.S
+      x86_64/chkstk_darwin.S
       x86_64/floatdidf.c
       x86_64/floatdisf.c
       x86_64/floatdixf.c


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40856.125615.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171205/d5ff656c/attachment.bin>


More information about the llvm-commits mailing list