[LLVMdev] Dereference PointerType?

Daniel Waterworth da.waterworth at googlemail.com
Tue Oct 20 04:25:41 PDT 2009


It may not be the best way to do what I'm trying to do, but it's not useless
and bogus. Consider the following:

%1 = alloca i32* ; %1 is of type i32**, dereferenced it becomes a type i32*
and
                         ; the size of that is sizeof(void *) bytes

Having said that I am looking at the target data getTypeAllocSize method.

Daniel

2009/10/20 Duncan Sands <baldrick at free.fr>

> Óscar Fuentes wrote:
>
>> Daniel Waterworth <da.waterworth at googlemail.com> writes:
>>
>> [snip]
>>
>> Use the getElementType method of PointerType.
>>
>>  size_t size;
>>>> if (isa<PointerType>(allocated_type)) {
>>>>  size = sizeof(void*) * 8;
>>>> } else {
>>>>  size = allocated_type->getPrimitiveSizeInBits();
>>>> }
>>>> // size now equals the size (in bits) of the type allocated
>>>>
>>>
>> This looks suspicious to me.
>>
>
> Probably he wants getTypeAllocSize (available from target data).  The
> special casing of PointerType is both useless and bogus.
>
> Ciao,
>
> Duncan.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091020/9ae51bb3/attachment.html>


More information about the llvm-dev mailing list