This is an archive of the discontinued LLVM Phabricator instance.

[Darwin] Add a new -mstack-probe option and enable by default
AbandonedPublic

Authored by aemerson on Dec 5 2017, 3:07 PM.

Details

Summary

Add a new -mstack-probe and -mno-stack-probe option to enable the generation of stack probing functions on non-Windows platforms, if supported. This patch only enables this for Darwin.

Diff Detail

Repository
rC Clang

Event Timeline

Gerolf added a subscriber: Gerolf.

It looks pretty straightforward, but I'd ask (at least) Duncan or Akira, and Matthias to review this more carefully.

-Gerolf

ahatanak added inline comments.Dec 5 2017, 10:14 PM
lib/CodeGen/BackendUtil.cpp
442

Is there a reason you can't use function attributes "probe-stack"="___chkstk_darwin" and "stack-probe-size"=4096 instead of setting a TargetOptions flag here? If you intend to use stack probing with LTO, I think you need function attributes. Also, it looks like that would simplify the changes made to X86 backend.

lib/Driver/ToolChains/Clang.cpp
3955

Just to confirm, is stack probing going to be enabled unconditionally on Darwin unless the user disables it with mno-stack-probe?

aemerson added inline comments.Dec 6 2017, 6:46 AM
lib/CodeGen/BackendUtil.cpp
442

I don't think there's any reason not to. Is it worth specifying the probe size itself given that it'll be a known fixed value? It could be misleading to give a probe size which only has a single valid value for Darwin.

lib/Driver/ToolChains/Clang.cpp
3955

Yes that's the intention. However on D40863 there's discussion that it might be better to restrict to newer Darwin targets.

ahatanak added inline comments.Dec 6 2017, 11:45 AM
lib/CodeGen/BackendUtil.cpp
442

If 4096B is the only valid size for Darwin and the default size is 4096B in the backend, you can just add attribute "probe-stack"="___chkstk_darwin" to the function. The backend can check the existence of the attribute and decide whether to enable stack-probing.

Did this eventually go in?

aemerson abandoned this revision.May 16 2018, 3:39 AM

Did this eventually go in?

No, this approach was superseded. I will upstream a new implementation in the near future.