Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Dec 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/test/codegen/align-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down