1. [LICM] Hoisting of widenable conditions out of loops (details)
  2. [LICM] Support hosting of dynamic allocas out of loops (details)
Commit 787dba7aae1d01f3fcf1e471f733f00a6ba66e33 by listmail
[LICM] Hoisting of widenable conditions out of loops
The change itself is straight forward and obvious, but ... there's an
existing test checking for exactly the opposite. Both I and Artur think
this is simply conservatism in the initial implementation.  If anyone
bisects a problem to this, a counter example will be very interesting.
Differential Revision:
The file was modifiedllvm/lib/Transforms/Scalar/LICM.cpp
The file was modifiedllvm/include/llvm/IR/
The file was modifiedllvm/test/Transforms/LICM/explicit_guards.ll
Commit 8d22100f66c4170510c6ff028c60672acfe1cff9 by listmail
[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
(, 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:
The file was addedllvm/test/Transforms/LICM/hoist-alloca.ll
The file was modifiedllvm/lib/Transforms/Scalar/LICM.cpp