This is an archive of the discontinued LLVM Phabricator instance.

[PATCH 1/2] Add a "probe-stack" attribute
Needs ReviewPublic

Authored by Zoxc on May 10 2015, 9:18 PM.

Details

Reviewers
majnemer
Summary

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.

Diff Detail

Event Timeline

Zoxc updated this revision to Diff 25439.May 10 2015, 9:18 PM
Zoxc retitled this revision from to [PATCH 1/2] Add a "probe-stack" attribute.
Zoxc updated this object.
Zoxc edited the test plan for this revision. (Show Details)
Zoxc added a reviewer: majnemer.
Zoxc set the repository for this revision to rL LLVM.
Zoxc updated this revision to Diff 25443.May 10 2015, 10:20 PM
Zoxc removed rL LLVM as the repository for this revision.
majnemer added a subscriber: Unknown Object (MLST).May 10 2015, 10:58 PM
majnemer edited edge metadata.May 10 2015, 11:03 PM

The MachineFunction changes should be in D9654. The inliner changes need a testcase.

include/llvm/CodeGen/MachineFunction.h
286 ↗(On Diff #25443)

Please make this function const.

Zoxc updated this revision to Diff 25445.May 10 2015, 11:30 PM
Zoxc edited edge metadata.
Zoxc updated this revision to Diff 25446.May 10 2015, 11:58 PM

Added the test

majnemer added inline comments.May 11 2015, 8:37 PM
lib/Transforms/IPO/Inliner.cpp
100

Any reason why this can't just be Caller->addFnAttr("probe-stack"); ?

Zoxc added a comment.Jul 16 2015, 3:30 PM

majnemer: Do you have any objections to merging this?

In D9653#206756, @Zoxc wrote:

majnemer: Do you have any objections to merging this?

I'd be far more comfortable if probe-stack took an argument instead of hard coding the name a specific stack probing function.

Zoxc added a comment.Jul 16 2015, 9:44 PM

"probe-stack" is only intended to guarantee that a guard page can be triggered, not to dictate how. __probestack is intended to be added to compiler-rt as to aid implementation (and Windows toolchains have existing functions for this). Ideally LLVM would inline it (as GCC does), but that would require more invasive changes to X86FrameLowering (emitPrologue does not seem like the ideal place to emit a loop).

Zoxc updated this revision to Diff 31607.Aug 8 2015, 8:03 PM

Added documentation.

Zoxc updated this revision to Diff 54606.Apr 21 2016, 9:10 PM

Rebased patch

@majnemer ping? I am also interested in this.