On 11/18/12 11:16 AM, Eduardo wrote:> Hi,
>
> How can I get the size of a global variable if I have a reference to
> the corresponding llvm::GlobalVariable object? What if this variable
> is an array or struct, how can I get the size of the whole variable?
A GlobalVariable will always have a pointer type. Find the contained
type of the pointer type, and then use the DataLayout class to determine
the size of the contained type.
See
http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/lib/InsertPoolChecks/RegisterBounds.cpp?revision=168085&view=markup
for an example.
-- John T.
>
> Thanks in advance,
> Eduardo
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev