Skip to content

Commit 946f8e6

Browse files
committed
Use primitive align for tagged enum fill.
Hopefully will fix assert on ARM where vector types are being used as the fill type for enums containing repr aligned types greater than the largest possible native type, thus don't match the Layout's alignment and triggers an assert.
1 parent c219cdf commit 946f8e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/librustc_trans/adt.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
185185
}
186186
}
187187
}
188-
layout::General { discr, size, align, .. } => {
188+
layout::General { discr, size, align, primitive_align, .. } => {
189189
// We need a representation that has:
190190
// * The alignment of the most-aligned field
191191
// * The size of the largest variant (rounded up to that alignment)
@@ -198,14 +198,15 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
198198
// of the size.
199199
let size = size.bytes();
200200
let align = align.abi();
201+
let primitive_align = primitive_align.abi();
201202
assert!(align <= std::u32::MAX as u64);
202203
let discr_ty = Type::from_integer(cx, discr);
203204
let discr_size = discr.size().bytes();
204205
let padded_discr_size = roundup(discr_size, align as u32);
205206
let variant_part_size = size-padded_discr_size;
206-
let variant_fill = union_fill(cx, variant_part_size, align);
207+
let variant_fill = union_fill(cx, variant_part_size, primitive_align);
207208

208-
assert_eq!(machine::llalign_of_min(cx, variant_fill), align as u32);
209+
assert_eq!(machine::llalign_of_min(cx, variant_fill), primitive_align as u32);
209210
assert_eq!(padded_discr_size % discr_size, 0); // Ensure discr_ty can fill pad evenly
210211
let fields: Vec<Type> =
211212
[discr_ty,

0 commit comments

Comments
 (0)