[LLVMdev] Order of fiels and structure usage

Eli Friedman eli.friedman at gmail.com
Sat Sep 13 19:50:44 PDT 2008


On Sat, Sep 13, 2008 at 7:22 PM, Hendrik Boom <hendrik at topoi.pooq.com> wrote:
> Just curious -- would struct{struct{i32, i8} i8} take just 6 bytes on the
> usual architectures.

No... it would take 12 bytes.  Assuming i32 has 4 byte ABI alignment,
struct {i32, i8} has to have alignment 4 and size 8, and therefore
struct{struct{i32, i8} i8} would have to have alignment 4 and size 8.
The rules for LLVM struct alignment and size come from the usual C ABI
for structs.

struct {i32,i8,i8}, on the other hand, only takes 8 bytes.

-Eli



More information about the llvm-dev mailing list