rustc: don't unpack newtypes of scalar-pairs with mismatched alignment.
This commit is contained in:
parent
bb42071f63
commit
d455955445
2 changed files with 14 additions and 1 deletions
|
@ -1079,7 +1079,9 @@ impl<'a, 'tcx> LayoutDetails {
|
||||||
// We have exactly one non-ZST field.
|
// We have exactly one non-ZST field.
|
||||||
(Some((i, field)), None, None) => {
|
(Some((i, field)), None, None) => {
|
||||||
// Field fills the struct and it has a scalar or scalar pair ABI.
|
// Field fills the struct and it has a scalar or scalar pair ABI.
|
||||||
if offsets[i].bytes() == 0 && size == field.size {
|
if offsets[i].bytes() == 0 &&
|
||||||
|
align.abi() == field.align.abi() &&
|
||||||
|
size == field.size {
|
||||||
match field.abi {
|
match field.abi {
|
||||||
// For plain scalars we can't unpack newtypes
|
// For plain scalars we can't unpack newtypes
|
||||||
// for `#[repr(C)]`, as that affects C ABIs.
|
// for `#[repr(C)]`, as that affects C ABIs.
|
||||||
|
|
|
@ -57,3 +57,14 @@ pub fn pkd_pair(pair1: &mut PackedPair, pair2: &mut PackedPair) {
|
||||||
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{.*}}, i8* %{{.*}}, i{{[0-9]+}} 5, i32 1, i1 false)
|
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{.*}}, i8* %{{.*}}, i{{[0-9]+}} 5, i32 1, i1 false)
|
||||||
*pair2 = *pair1;
|
*pair2 = *pair1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct PackedNestedPair((u32, u32));
|
||||||
|
|
||||||
|
// CHECK-LABEL: @pkd_nested_pair
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn pkd_nested_pair(pair1: &mut PackedNestedPair, pair2: &mut PackedNestedPair) {
|
||||||
|
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{.*}}, i8* %{{.*}}, i{{[0-9]+}} 8, i32 1, i1 false)
|
||||||
|
*pair2 = *pair1;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue