Description
Right now, we compute a struct's padding fields while we are codegen'ing it.
Instead, we should have a dedicated phase for computing implicit padding fields that transforms from structs-with-only-explicit-fields to structs-with-explicit-fields-and-implicit-padding-fields.
Benefits this will give us:
-
The ability to precisely derive various traits for structs with large alignment (right now we are conservatively pessimistic). See for example https://github.com/rust-lang-nursery/rust-bindgen/blob/b13f0766e28cf75dd04f358bf64d87ea96b111c3/src/ir/analysis/derive_debug.rs#L160-L170
-
Separation of concerns, simpler code
This new phase should probably happen either right before or right after we compute allocation units for bitfields. I'm not 100% sure which, and determining it requires further investigation/experimentation.
Activity