[PATCH] D68720: Support -fstack-clash-protection for x86

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 9 14:22:09 PDT 2019


serge-sans-paille added a comment.

@efriedma : there's indeed an intersection with the `probe-stack` attribute. The `probe-stack` attribute (a) forces a function call, and (b) this function call only happens **before** the stack gets expanded.

(a) is probably a performance issue in several cases, plus it requires an extra register (that's mentioned in  https://reviews.llvm.org/D9653) 
(b) is an issue, as pointed out in https://lwn.net/Articles/726587/ (grep for valgrind)  : from valgrind point of view, accessing un-allocated stack memory triggers error, and we probably want to please valgrind

Doing the call *after* the stack allocation is also not an option, as a signal could be raised between the stack allocation and the stack probing, escaping the stack probe if a custom signal handler is executed.

That being said, I do think it would be a good thing to have a special value for `probe-stack`, say `probe-stack=inline-asm`, that would trigger generation of inlined assembly as I do. That way we have all the pieces in one place, with different strategies. And we would have clang set the attribute for each function when `-fstack-clash-protection` is given.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68720/new/

https://reviews.llvm.org/D68720





More information about the cfe-commits mailing list