Description
Since we don't have to worry about FFI interop for types that are not #[repr(C)]
, this means we can perform certain optimizations with regards to padding. One such optimization is collapsing trailing padding. For example std::mem::size_of::<((u16, u8), u8)>()
returns 6, but ideally it would be 4.
To implement this size optimization would require keeping track of two separate sizes, one being the actual size not including trailing padding, and the other being the array element size or aligned size. For example (u16, u8)
would have an actual size of 3, but an array size of 4.
As an added benefit, this would allow for enums to use that extra space at the end to store the discriminant.
This likely depends on teaching LLVM to support this sort of stuff.