LLVM alignment of nested structs/arrays
<p>I want to get the exact byte representation of nested struct/array datatypes. For example the following C struct:</p>

<pre><code>typedef struct zTy {
    int x;
    char c[2];
    struct  { char d; } v;
} z;
</code></pre>

<p>It gets converted to the following LLVM IR:</p>

<pre><code>%struct.zTy = type { i32, [2 x i8], %struct.anon }
%struct.anon = type { i8 }

%a = alloca %struct.zTy, align 4
</code></pre>

<p>From the alloca instruction it is possible to see the alignment (4 byte). But I don't know where this alignment is inserted or how alignment for nested structs is calculated.
I get the total size of the struct for my target triple using getTypeAllocSize():</p>

<pre><code>AllocaInst* AI;
Module &amp;M;
Type* T = AI-&gt;getAllocatedType();
int size = M.getDataLayout()-&gt;getTypeAllocSize(T) // 8 Byte
</code></pre>

<p>Is there a way to determine the exact layout for arbitrary nested datatypes for my target architecture from a LLVM pass?</p>