[PATCH] D149563: [TRE] Mark alloca's as escaped if their call does not write memory

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 23:43:13 PDT 2023


caojoshua added a comment.

In D149563#4310611 <https://reviews.llvm.org/D149563#4310611>, @efriedma wrote:

> There are basically two ways a pointer can be "captured": it can be written to memory, or it can be returned.
>
> The code here is trying to reason more deeply about `memory(none)` functions: the `memory(none)` implies no writes to memory, so the only way a pointer can be captured is by returning it. The code follows the return value to figure out if it's actually used.  So the tail markings in test17 and test18 should be fine, I think.

OK, I think I'm starting to understand this better. Looking at the function attributes doc <https://llvm.org/docs/LangRef.html#function-attributes>, I think we can slightly strengthen this to not escape for `memory(read, argmem: readwrite)`. Right not, we always escape if the callee can write to memory, but we actually don't need to escape if the callee is only writing to argmems. Please see these examples: https://godbolt.org/z/qzj76rhah. Does this make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149563



More information about the llvm-commits mailing list