[llvm-dev] Difference between AllocaInst::getType() vs AllocaInst::getAllocatedType()

John Criswell via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 10 09:05:33 PDT 2017


On 6/10/17 9:39 AM, Dipanjan Das via llvm-dev wrote:
>
> From the documentation, I can't understand the difference 
> between AllocaInst::getType() vs AllocaInst::getAllocatedType() 
> methods. Can anyone please enlighten me?

The AllocaInst instruction allocates stack memory.  The value that it 
returns is always a pointer to memory.

You should run an experiment to double-check this, but I believe 
AllocaInst::getType() returns the type of the value that is the result 
of the alloca while AllocaInst::getAllocatedType() returns the type of 
the value that is allocated.  For example, if the alloca allocates a 
struct {int ; int}, then getAllocatedType() returns a struct type and 
getType() return a "pointer to struct" type.

Regards,

John Criswell

>
> -- 
>
> Thanks & Regards,
>
> Dipanjan
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170610/e877f91f/attachment.html>


More information about the llvm-dev mailing list