[llvm-dev] RFC: Adding argument allocas

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 12 15:03:08 PST 2016


On Sat, Dec 10, 2016 at 8:20 AM, Hal Finkel <hfinkel at anl.gov> wrote:

> Having an alloca with an initializer seems like a reasonable enhancement.
> Please, however, without all of these special restrictions: any value
> should be accepted on any alloca. We can match the special argument cases
> in the backend and otherwise lower to the equivalent of an alloca+store.
>

We can definitely generalize this to alloca initializers, but there's very
little reason for frontends to initialize allocas that aren't arguments.
Typically allocas for locals must live in the entry block, while
initialization might be buried in some conditionally executed code. A
frontend would have to know that the initializer doesn't depend on local
computation, and that hoisting the store to the entry block doesn't
pessimize the code. With arguments, the value is always available, and the
notional store will be optimized away or is needed in a debug build.

So, even though I think arbitrary alloca initializers are a reasonable
extension to the LLVM IR model, I don't see enough of a use case to add the
general feature. I'd rather have a feature that does one thing well rather
than trying to be overly general (e.g. llvm.lifetime.start).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161212/f2bf20bc/attachment.html>


More information about the llvm-dev mailing list