Description
If I have a struct Option<uint>
, the way that we represent this today is via struct { u8 tag; uint value; }
. This is ideal for discriminant size, and even for struct size. The bad part is that we add explicit padding (7 bytes on 64-bit machines) to make up for the middle padding. This leads to horrible things like unaligned moves in LLVM and alloca's of 7 bytes.
I believe that it may actually be better for a discriminant to be the smallest size above or equal to the maximum alignment of the struct. So in the above case the discriminant would actually become uint
, and for Option<u8>
it would remain u8
. This would remove any padding between the discriminant and the beginning of the data.
cc @jld, I think this would remove some need for tbaa.struct
for now, although we'll still want that eventually. I'm also not sure if reading a word is more efficient than reading a byte, but it kinda seems so to me?