HomePhabricator

[LICM] Support hosting of dynamic allocas out of loops

Authored by reames on Nov 8 2019, 7:04 AM.

Description

[LICM] Support hosting of dynamic allocas out of loops

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.

Differential Revision: https://reviews.llvm.org/D69227

Details

Committed
reamesNov 8 2019, 8:19 AM
Differential Revision
D69227: [LICM] Support hosting of dynamic allocas out of loops
Parents
rG787dba7aae1d: [LICM] Hoisting of widenable conditions out of loops
Branches
Unknown
Tags
Unknown