[PATCH] D113520: [SROA] Spill alloca's around non-capturing escapes via calls to allow alloca partitioning/promotion

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 9 15:01:06 PST 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, huntergr, jdoerfert, rampitec, Carrot, nikic.
lebedev.ri added a project: LLVM.
Herald added subscribers: hiraditya, mgorny.
lebedev.ri requested review of this revision.

This is inspired by the original variant of D109749 <https://reviews.llvm.org/D109749> by Graham Hunter,
but is a more general version that i proposed in https://reviews.llvm.org/D109749#2999389

In D109749#2999389 <https://reviews.llvm.org/D109749#2999389>, @lebedev.ri wrote:

> 1. duplicate the original alloca (only for simplicity, this is fine since we know the old alloca goes away)
> 2. before each capture, load contents of the old alloca, and store it into new alloca
> 3. after each capture, load contents of the new alloca, and store it into old alloca
> 4. change captures to refer to the new alloca
> 5. run AggLoadStoreRewriter on the new alloca - so that all the uses of old alloca we've just introduced are analyzeable by SROA
> 6. proceed with normal handling of the old alloca - mem2reg will now succeed

Here, the algorithm is fully integrated into the SROA workloop,
and is not limited to the full-alloca escapes, but gracefully handles offset pointers escaping.
Also, we need to be careful with reloading - we need to do that on the every path
after the instruction, and there could be more than a single such path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113520

Files:
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Transforms/PhaseOrdering/lifetime-sanitizer.ll
  llvm/test/Transforms/SROA/non-capturing-call.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113520.385987.patch
Type: text/x-patch
Size: 20089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211109/2a76647f/attachment.bin>


More information about the llvm-commits mailing list