[PATCH] D69227: [LICM] Support hosting of dynamic allocas out of loops

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 16:25:24 PDT 2019


reames created this revision.
reames added reviewers: nlewycky, fedor.sergeev, apilipenko.
Herald added subscribers: asbirlea, bollu, mcrosier.
Herald added a project: LLVM.

This patch implements a correct, but not terribly useful, transform.  In particular, if we have a dynamic alloca in a loop which is guaranteed to execute, and provably not captured, we hoist the alloca out of the loop.  The capture tracking is needed so that we can prove that each previous stack region dies before the next one is allocated.  The transform decreases the amount of stack allocation needed by a linear factor (e.g. the iteration count of the loop).

Now, I really hope no one is actually using dynamic allocas.  As such, why this patch?

Well, the actual problem I'm hoping to make progress on is allocation hoisting.  There's a large draft patch out for review (https://reviews.llvm.org/D60056), and this patch was the smallest chunk of testable functionality I could come up with which takes a step vaguely in that direction.

Once this is in, it makes motivating the changes to capture tracking mentioned in TODOs testable.  After that, I hope to extend this to trivial malloc free regions (i.e. free dominating all loop exits) and allocation functions for GCed languages.


Repository:
  rL LLVM

https://reviews.llvm.org/D69227

Files:
  lib/Transforms/Scalar/LICM.cpp
  test/Transforms/LICM/hoist-alloca.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69227.225807.patch
Type: text/x-patch
Size: 8186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191020/440f2a98/attachment-0001.bin>


More information about the llvm-commits mailing list