Closed ambiguousname closed 1 month ago
The padding is determined by the previous type
Or the previous set of types, (u8, u16, u32)
will have an i8
padding. It's unclear to me if this is a global decision or per-alignment-section. I'll write out a bunch of test structs to reverse engineer this.
Also the example was incorrect, Bar
should have no u8
s.
Or the previous set of types,
(u8, u16, u32)
will have ani8
padding. It's unclear to me if this is a global decision or per-alignment-section. I'll write out a bunch of test structs to reverse engineer this.
Nope, it pads with an i8
and then an i16
. Previous type is right, the u16
needs to be padded too.
Should double check with LLVM output, but basically:
Pads with
2 x i8
s. ButPads with
1 x i16
. The padding is determined by the previous type, and then it all gets converted intoi32
s for WASM, regardless of how much sense that makes.So, the fix should go in
generate_fields
, to grab what the previous field's align is. Then update the padding to be use something like(next_offset - curr_offset - field_layout.size()) / previous_align