[llvm-dev] [LLVMdev] Adding a stack probe function attribute

John Kåre Alsaker via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 30 13:16:43 PDT 2015

I've submited my patch to inline stack probes here:

On Mon, Aug 17, 2015 at 7:46 PM, Andy Ayers <andya at microsoft.com> wrote:
> The stack pointer can't ever safely point beyond the valid range. I don't 100% know the exact reason but suspect the OS may verify this on context save/restore, which can happen unpredictably. This can be tricky to guarantee if you're modifying the stack pointer in flight without some extra math here and there, at which point you might as well use another register and defer the update like we do.
> I'm also not sure what you mean by updating the stack pointer being "allowed" for x86-32 -- if you look at the implementation of __chkstk for x86-32, which we provide in sources with VS, it does not modify ESP in the loop -- it uses EAX to probe the stack.
I was thinking of the fact that __chkstk modified SP on x86-32, but
not on x86-64.

> We have the same issue with epilogs that you saw. We've worked around it for now by generating epilogs first, but this seems a bit hacky. I'd like to see us fix this by delaying the inline expansion of a stack probe until after prolog/epilog generation. That also removes the need for us to update the prolog block in ::emitProlog, which is a bit clunky. But we haven't gotten around to this yet.
Hm.. I did try just generating epilogs first, but I ran into test failures.

More information about the llvm-dev mailing list