I’m attempting to implement the #[repr(align)] RFC which is jumping in the deep end slightly with my level of knowledge about Rust compiler internals. I managed to get parsing an align repr and setting alignment of the struct such that mem::align_of returns the right thing for my aligned type. However mem::size_of is not returning the aligned size and I’m not totally sure what the correct way to do this is.
If I create this aligned type in C++:
struct alignas(16) Align16 {
int i;
};
The IR type generated from Clang is:
%struct.Align16 = type { i32, [12 x i8] }
My similarly aligned type in Rust is missing the [12 xi8]. I wasn’t sure if I’d need to add padding or if LLVM would pad the layout to the alignment, but it seems that it’s something that needs to be handled on the Rust side of things. Does that sound correct, the way to get the type sized correctly would be to add padding bytes to the struct layout? If so, where would be the place to do this in the code? I figure someone here might be able to point me in the right direction 