From ed54b4a7985000624229f2375233eb3c6a9b23fc Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 21 Jun 2017 18:46:50 +0000 Subject: Add a "probe-stack" attribute This attribute is used to ensure the guard page is triggered on stack overflow. Stack frames larger than the guard page size will generate a call to __probestack to touch each page so the guard page won't be skipped. Reviewed By: majnemer Differential Revision: https://reviews.llvm.org/D34386 llvm-svn: 305939 --- llvm/lib/IR/Attributes.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib/IR/Attributes.cpp') diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index a518f7b5c81..ba2ec93ac24 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1638,6 +1638,13 @@ static void adjustCallerSSPLevel(Function &Caller, const Function &Callee) { Caller.addFnAttr(Attribute::StackProtect); } +/// \brief If the inlined function required stack probes, then ensure that +/// the calling function has those too. +static void adjustCallerStackProbes(Function &Caller, const Function &Callee) { + if (!Caller.hasFnAttribute("probe-stack") && Callee.hasFnAttribute("probe-stack")) + Caller.addFnAttr("probe-stack", Callee.getFnAttribute("probe-stack").getValueAsString()); +} + #define GET_ATTR_COMPAT_FUNC #include "AttributesCompatFunc.inc" -- cgit v1.2.3