[PATCH] D135783: [FunctionAttrs] Account for memory effects of inalloca/preallocated

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 12 13:58:32 PDT 2022


rnk added a comment.

In D135783#3853445 <https://reviews.llvm.org/D135783#3853445>, @nikic wrote:

>> Another wrinkle is the existence of callee-cleanup conventions. On Windows, all methods and many other functions adjust the stack to clear the memory used to pass their arguments. In some sense, this means that the allocas are automatically cleared by the call. However, LLVM instead models this as a write of undef to all of the inalloca values passed to the call instead of a stack adjustment. Frontends should still restore the stack pointer to avoid a stack leak.

I don't recall why I thought modelling it as a "write of undef" was better than saying it deallocated the memory. It's effectively the same result as a stackrestore, which can be used to deallocate dynamic allocas.

It also kind of doesn't matter whether the call is callee cleanup, because it is valid for a pass to place a side-effect free call immediately after the call that uses inalloca.


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

https://reviews.llvm.org/D135783



More information about the llvm-commits mailing list