1
Fork 0

rustc: don't use union layouts for tagged union enums.

This commit is contained in:
Eduard-Mihai Burtescu 2017-12-26 01:40:48 +02:00
parent 269827ced9
commit 97228f5e7b
2 changed files with 7 additions and 6 deletions

View file

@ -1655,10 +1655,10 @@ impl<'a, 'tcx> LayoutDetails {
discr,
variants
},
// FIXME(eddyb): using `FieldPlacement::Arbitrary` here results
// in lost optimizations, specifically around allocations, see
// `test/codegen/{alloc-optimisation,vec-optimizes-away}.rs`.
fields: FieldPlacement::Union(1),
fields: FieldPlacement::Arbitrary {
offsets: vec![Size::from_bytes(0)],
memory_index: vec![0]
},
abi,
align,
size

View file

@ -32,13 +32,14 @@ pub enum Enum4 {
A(i32),
B(i32),
}
// CHECK: %Enum4 = type { [2 x i32] }
// CHECK: %Enum4 = type { [0 x i32], i32, [1 x i32] }
// CHECK: %"Enum4::A" = type { [1 x i32], i32, [0 x i32] }
pub enum Enum64 {
A(Align64),
B(i32),
}
// CHECK: %Enum64 = type { [16 x i64] }
// CHECK: %Enum64 = type { [0 x i32], i32, [31 x i32] }
// CHECK: %"Enum64::A" = type { [8 x i64], %Align64, [0 x i64] }
// CHECK-LABEL: @align64