[llvm-dev] A pass which moves AllocaInst into function entry block?

mats petersson via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 5 09:51:11 PST 2017


In my compiler, I wrote code to always put alloca at the entry of a
function (basically, "figure out current function, find first basic block,
insert alloca into the bb").

Is this for your own compiler, for clang, or something other use? [I was
under the impression that clang did this too, but I may be wrong]

--
Mats

On 5 January 2017 at 16:47, Johnson, Nicholas Paul via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Is there an existing LLVM pass which moves alloca instructions into the
> function entry block?  In particular, I am seeing an alloca which is ideal
> for this movement: the alloca is not in the function entry block, it
> allocates a constant size, it is *not* within a loop, and it is in a block
> which post-dominates the function entry (i.e., it invariably executes with
> every function invocation).
>
> I think this movement normally happens as during the function inlining
> process.  I'm not sure why it hasn't occurred in this case, but whatever
> the reason, the poor alloca placement inhibits later optimizations,
> especially SROA, so I would like to fix it.
>
> Nick Johnson
> D. E. Shaw Research
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170105/de5a1bc3/attachment.html>


More information about the llvm-dev mailing list