[llvm-dev] Understanding AllocaInst
David Greene via llvm-dev
llvm-dev at lists.llvm.org
Fri Nov 8 12:48:10 PST 2019
David Blaikie via llvm-dev <llvm-dev at lists.llvm.org> writes:
> The type of an alloca is a pointer to the type of the allocated object. For
> instance:
>
> This C++ source code:
>
> int i;
> float f;
> f1(i, f);
>
> compiles to this LLVM IR:
>
> %i = alloca i32, align 4
> %f = alloca float, align 4
> %0 = load i32, i32* %i, align 4
> %1 = load float, float* %f, align 4
> call void @_Z2f1if(i32 %0, float %1)
>
> So you can see the type of an alloca of i32 is i32* and the type of an
> alloca of float is float*.
And the type of an alloca of i32* is i32** which is where that comes
from. So Avery is doing an alloca of an i32*, a pointer rather than an
integer.
HTH,
-David
More information about the llvm-dev
mailing list