[llvm-dev] Get the variable size and count from AllocaInst IR instruction

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 10 05:03:14 PDT 2017


+llvm-dev list

2017-06-10 20:02 GMT+08:00 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw>:

> Refer to [1], I believe you can use `getArraySize()` and `getType()` to
> get what you want.
> Of course, you have to make sure the alloca does allocate an array by
> using `isArrayAllocation()`.
>
> [1] http://llvm.org/doxygen/classllvm_1_1AllocaInst.html
>
> HTH,
> chenwj
>
>
> 2017-06-10 14:49 GMT+08:00 Dipanjan Das via llvm-dev <
> llvm-dev at lists.llvm.org>:
>
>>
>> Let's say we the following: AllocaInst *alloca_inst =
>> dyn_cast<AllocaInst>(&I) // I = instruction
>> Corresponding alloca instructions in IR are as follows:
>>
>> %var1 = alloca [3 x i32], align 4
>> %var2 = alloca i32*, align 8
>>
>> How can I have the size and count (in case of array) of the allocated
>> variables?
>>
>> --
>>
>> Thanks & Regards,
>> Dipanjan
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>
>
> --
> Wei-Ren Chen (陳韋任)
> Homepage: https://people.cs.nctu.edu.tw/~chenwj
>



-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170610/cdfab4cf/attachment.html>


More information about the llvm-dev mailing list