[LLVMdev] Structure Types and ABI sizes
Renato Golin
rengolin at systemcall.org
Fri Mar 4 05:05:25 PST 2011
On 4 March 2011 12:51, Jochen Wilhelmy <j.wilhelmy at arcor.de> wrote:
> why would it break C code? of course a C frontend should generate only
> tailpadded types.
It's not about the size, but the offset. If you had a char field in
the inherited class:
%I' = type { %I, i8, tailpad};
The offset of that i8 has to be 8, not 5. If all structures are
packed, that would be 5, which is correct for non-POD in C++ but wrong
for everything else.
> %J = type { inherit %I, i8 }
>
> the inherit keyword before %I removes the tailpadding
That's what the packed is for.
%Base = type { i32, i8 }; // size = 8
%POSDerived = type { %Base, i8 }; // i8 offset = 8, size 12
%Basep = packed type { i32, i8 }; // size = 5
%nonPOSDerived = type { %Basep, i8 }; // i8 offset = 5, size 8
cheers,
--renato
More information about the llvm-dev
mailing list