[PATCH] Add a "probe-stack" attribute
John Kåre Alsaker
john.mailinglists at gmail.com
Wed Aug 6 22:31:29 PDT 2014
Split from http://reviews.llvm.org/D4717
http://reviews.llvm.org/D4820
Files:
include/llvm/CodeGen/MachineFunction.h
lib/CodeGen/MachineFunction.cpp
lib/Transforms/IPO/Inliner.cpp
Index: include/llvm/CodeGen/MachineFunction.h
===================================================================
--- include/llvm/CodeGen/MachineFunction.h
+++ include/llvm/CodeGen/MachineFunction.h
@@ -265,6 +265,13 @@
/// Should we be emitting segmented stack stuff for the function
bool shouldSplitStack();
+ /// Should we be probing the stack for the function.
+ /// Probing the stack means that we must read or write to the stack on every
+ /// page. This is to ensure that a guard page will be hit and stack overflow
+ /// can be detected. We insert instructions to do this when allocating from
+ /// the stack.
+ bool shouldProbeStack();
+
/// getNumBlockIDs - Return the number of MBB ID's allocated.
///
unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); }
Index: lib/CodeGen/MachineFunction.cpp
===================================================================
--- lib/CodeGen/MachineFunction.cpp
+++ lib/CodeGen/MachineFunction.cpp
@@ -134,6 +134,15 @@
return getFunction()->hasFnAttribute("split-stack");
}
+/// Should we be probing the stack for the function.
+/// Probing the stack means that we must read or write to the stack on every
+/// page. This is to ensure that a guard page will be hit and stack overflow
+/// can be detected. We insert instructions to do this when allocating from
+/// the stack.
+bool MachineFunction::shouldProbeStack() {
+ return getFunction()->hasFnAttribute("probe-stack");
+}
+
/// RenumberBlocks - This discards all of the MachineBasicBlock numbers and
/// recomputes them. This guarantees that the MBB numbers are sequential,
/// dense, and match the ordering of the blocks within the function. If a
Index: lib/Transforms/IPO/Inliner.cpp
===================================================================
--- lib/Transforms/IPO/Inliner.cpp
+++ lib/Transforms/IPO/Inliner.cpp
@@ -137,6 +137,12 @@
AdjustCallerSSPLevel(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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4820.12269.patch
Type: text/x-patch
Size: 2389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140807/dfee7673/attachment.bin>
More information about the llvm-commits
mailing list