Index: include/llvm/CodeGen/MachineFunction.h =================================================================== --- include/llvm/CodeGen/MachineFunction.h +++ include/llvm/CodeGen/MachineFunction.h @@ -278,6 +278,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 @@ -130,6 +130,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 @@ -132,6 +132,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.