This is an archive of the discontinued LLVM Phabricator instance.

[X86] Elide references to _chkstk for dynamic allocas
ClosedPublic

Authored by majnemer on Feb 27 2016, 12:52 AM.

Details

Summary

The _chkstk function is called by the compiler to probe the stack in an
order consistent with Windows' expectations. However, it is possible to
elide the call to _chkstk and manually adjust the stack pointer if we
can prove that the allocation is fixed size and smaller than the probe
size.

This shrinks chrome.dll, chrome_child.dll and chrome.exe by a
cummulative ~133 KB.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 49292.Feb 27 2016, 12:52 AM
majnemer retitled this revision from to [X86] Elide references to _chkstk for dynamic allocas.
majnemer updated this object.
majnemer added reviewers: rnk, hans.
majnemer added a subscriber: llvm-commits.
hans accepted this revision.Feb 29 2016, 2:40 PM
hans edited edge metadata.

Nice! lgtm

lib/Target/X86/X86ISelLowering.cpp
16377 ↗(On Diff #49292)

Can we check whether the alloca is dynamic or not, or is that hard to figure out from here?

16379 ↗(On Diff #49292)

s/it's/its/

This revision is now accepted and ready to land.Feb 29 2016, 2:40 PM
rnk added inline comments.Mar 1 2016, 10:59 AM
lib/Target/X86/X86ISelLowering.cpp
16365 ↗(On Diff #49292)

Can we name this something like CheckStack instead? I interpreted Lower to mean "lower this to modifying ESP directly".

16377 ↗(On Diff #49292)

I don't think we need to think about the frame pointer at all for dynamic allocas. If we're concerned that there haven't been any accesses to top-of-stack since the prologue, we could instead emit an inline stack probe (orl $0, (%esp)) here.

rnk accepted this revision.Mar 1 2016, 10:59 AM
rnk edited edge metadata.

lgtm

This revision was automatically updated to reflect the committed changes.