[LLVMdev] PHI and Allocas
Eli Friedman
eli.friedman at gmail.com
Thu Oct 1 20:15:08 PDT 2009
On Thu, Oct 1, 2009 at 2:35 PM, Renato Golin <rengolin at systemcall.org> wrote:
> As I'm always using alloca, the mem2reg pass seems to do the trick,
> but I'm not sure it would in all cases. The tutorial states that it
> works on all scalar values (I have no structs or arrays), so I believe
> I'm safe.
>
> Am I?
Yes, you're safe; if the alloca is a scalar and you don't do anything
other than load and store to the alloca, mem2reg will eliminate the
alloca regardless of the control flow. It's a fundamental property of
the algorithm to convert to SSA form; there's a comment in the source
code pointing to the paper in question if you're interested in the
theory.
-Eli
More information about the llvm-dev
mailing list