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*.
You can convert pointers to integers with a ptrtoint instruction. eg: %0
ptrtoint i32* %i to i64
On Fri, Nov 8, 2019 at 11:05 AM Avery Laird via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hello,
>
> Hopefully this is the correct place for this sort of question. I have been
> trying to do some simple instrumentation of LLVM IR, and I have been
> confused by the return type of alloca. When passing an AllocaInst as a
> parameter to a function call, the parameter type is i32**, which is not
> what I would expect. Really I would like the address of the allocated
> memory. What am I missing? And is it possible to represent the result of
> alloca as an integer? Thanks for any help.
>
> Cheers,
>
> Avery
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://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/20191108/a435d9e8/attachment.html>