[LLVMdev] Proposed: first class packed structures

Andrew Lenharth andrewl at lenharth.org
Fri Dec 8 06:27:18 PST 2006

On 12/8/06, Chris Lattner <clattner at apple.com> wrote:
> This patch isn't sufficient for two reasons: 1) it will turn structs that
> don't need to be packed into packed llvm structs.  2) it won't turn some
> that should be packed llvm structs into packed structs (e.g. strange ABI
> considerations force a field to be unaligned, not an attribute at the source
> level).
> Here's an example of #1:
>   extern struct { int x;  int y;  int z; } __attribute((packed)) foos;;
> This should just be {int,int,int}, not <{int,int,int}>.

no, consider
struct foo { int x;  int y;  int z; } __attribute((packed));
struct {char c; struct foo f;} bar;

sizeof(bar) == 13
if struct foo wasn't packed it's allignment would force a larger size for bar;


More information about the llvm-dev mailing list