[PATCH] D9653: [PATCH 1/2] Add a "probe-stack" attribute

John Kåre Alsaker via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 21:10:18 PDT 2016


Zoxc updated this revision to Diff 54606.
Zoxc added a comment.

Rebased patch


http://reviews.llvm.org/D9653

Files:
  docs/LangRef.rst
  lib/Transforms/IPO/Inliner.cpp
  test/Transforms/Inline/inline-probe-stack.ll

Index: test/Transforms/Inline/inline-probe-stack.ll
===================================================================
--- /dev/null
+++ test/Transforms/Inline/inline-probe-stack.ll
@@ -0,0 +1,12 @@
+; RUN: opt %s -inline -S | FileCheck %s
+
+define internal void @inner() "probe-stack" {
+  ret void
+}
+
+define void @outer() {
+  call void @inner()
+  ret void
+}
+; CHECK: define void @outer() #0
+; CHECK: attributes #0 = { "probe-stack" }
Index: lib/Transforms/IPO/Inliner.cpp
===================================================================
--- lib/Transforms/IPO/Inliner.cpp
+++ lib/Transforms/IPO/Inliner.cpp
@@ -94,6 +94,12 @@
 
   AttributeFuncs::mergeAttributesForInlining(*Caller, *Callee);
 
+  // If the callee requires stack probes, we ensure that the caller will
+  // require those too
+  if (Callee->hasFnAttribute("probe-stack")) {
+    Caller->addFnAttr("probe-stack");
+  }
+
   // Look at all of the allocas that we inlined through this call site.  If we
   // have already inlined other allocas through other calls into this function,
   // then we know that they have disjoint lifetimes and that we can merge them.
Index: docs/LangRef.rst
===================================================================
--- docs/LangRef.rst
+++ docs/LangRef.rst
@@ -1430,6 +1430,15 @@
     This attribute by itself does not imply restrictions on
     inter-procedural optimizations.  All of the semantic effects the
     patching may have to be separately conveyed via the linkage type.
+``"probe-stack"``
+    This attribute indicates that the function will trigger a guard region
+    in the end of the stack. It ensures that accesses to the stack must be
+    no further apart than the size of the guard region to a previous
+    access of the stack.
+
+    If a function that has a ``"probe-stack"`` attribute is inlined into a
+    function that doesn't have a ``"probe-stack"`` attribute, then the
+    resulting function will have a ``"probe-stack"`` attribute.
 ``readnone``
     On a function, this attribute indicates that the function computes its
     result (or decides to unwind an exception) based strictly on its arguments,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9653.54606.patch
Type: text/x-patch
Size: 2156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160422/5aa01fc5/attachment.bin>


More information about the llvm-commits mailing list