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 allocatedThis looks suspicious to me. Maybe you intented if (isa<PointerType>(allocated_type)) { size = sizeof(void*); } else { size = allocated_type->getPrimitiveSizeInBits() * 8; } but take a look at getPrimitiveSizeInBits' documentation to make sure that it is really what you want: http://llvm.org/doxygen/classllvm_1_1Type.html -- Óscar
Ó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.
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>