diff options
| author | The 8472 <git@infinite-source.de> | 2022-10-06 23:34:50 +0200 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2022-11-22 23:12:26 +0100 |
| commit | a3450d060d04b07c09775483b4d4bb7597429e5a (patch) | |
| tree | 660de009f4a4de793dc8d3e2085f568a07a34077 | |
| parent | 9f0cb566ea2f81392de6fb49b09c7e9b4ef4bf1d (diff) | |
| download | rust-a3450d060d04b07c09775483b4d4bb7597429e5a.tar.gz rust-a3450d060d04b07c09775483b4d4bb7597429e5a.zip | |
group fields based on largest power of two dividing its size
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 1505ce41b96..cf7a74dee99 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -140,14 +140,10 @@ fn univariant_uninterned<'tcx>( let optimizing = &mut inverse_memory_index[..end]; let effective_field_align = |f: &TyAndLayout<'_>| { if let Some(pack) = pack { - f.align.abi.min(pack) - } else if f.size.bytes().is_power_of_two() && f.size.bytes() >= f.align.abi.bytes() { - // Try to put fields which have a 2^n size and smaller alignment together with - // fields that have an alignment matching that size. - // E.g. group [u8; 4] with u32 fields - Align::from_bytes(f.align.abi.bytes()).unwrap_or(f.align.abi) + f.align.abi.min(pack).bytes() } else { - f.align.abi + // group [u8; 4] with align-4 or [u8; 6] with align-2 fields + f.align.abi.bytes().max(f.size.bytes()).trailing_zeros() as u64 } }; |
