[LLVMdev] get size of a GlobalVariable

John Criswell criswell at illinois.edu
Sun Nov 18 09:33:03 PST 2012

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.

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

More information about the llvm-dev mailing list