Auto merge of #41529 - bitshifter:issue-41479, r=eddyb
Add missing OperandPair struct field index adjustments. Fixes #41479.
This is a bug fix for a regression in 6d841da4a0.
This commit is contained in:
commit
a8ebd083fc
2 changed files with 36 additions and 3 deletions
|
|
@ -85,8 +85,15 @@ impl<'a, 'tcx> OperandRef<'tcx> {
|
|||
assert!(common::type_is_zero_size(ccx, ty));
|
||||
let llty = type_of::type_of(ccx, ty);
|
||||
let val = if common::type_is_imm_pair(ccx, ty) {
|
||||
let layout = ccx.layout_of(ty);
|
||||
let (ix0, ix1) = if let Layout::Univariant { ref variant, .. } = *layout {
|
||||
(adt::struct_llfields_index(variant, 0),
|
||||
adt::struct_llfields_index(variant, 1))
|
||||
} else {
|
||||
(0, 1)
|
||||
};
|
||||
let fields = llty.field_types();
|
||||
OperandValue::Pair(C_null(fields[0]), C_null(fields[1]))
|
||||
OperandValue::Pair(C_null(fields[ix0]), C_null(fields[ix1]))
|
||||
} else {
|
||||
OperandValue::Immediate(C_null(llty))
|
||||
};
|
||||
|
|
@ -156,8 +163,16 @@ impl<'a, 'tcx> OperandRef<'tcx> {
|
|||
if common::type_is_imm_pair(bcx.ccx, self.ty) {
|
||||
debug!("Operand::unpack_if_pair: unpacking {:?}", self);
|
||||
|
||||
let mut a = bcx.extract_value(llval, 0);
|
||||
let mut b = bcx.extract_value(llval, 1);
|
||||
let layout = bcx.ccx.layout_of(self.ty);
|
||||
let (ix0, ix1) = if let Layout::Univariant { ref variant, .. } = *layout {
|
||||
(adt::struct_llfields_index(variant, 0),
|
||||
adt::struct_llfields_index(variant, 1))
|
||||
} else {
|
||||
(0, 1)
|
||||
};
|
||||
|
||||
let mut a = bcx.extract_value(llval, ix0);
|
||||
let mut b = bcx.extract_value(llval, ix1);
|
||||
|
||||
let pair_fields = common::type_pair_fields(bcx.ccx, self.ty);
|
||||
if let Some([a_ty, b_ty]) = pair_fields {
|
||||
|
|
|
|||
18
src/test/run-pass/issue-41479.rs
Normal file
18
src/test/run-pass/issue-41479.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn split<A, B>(pair: (A, B)) {
|
||||
let _a = pair.0;
|
||||
let _b = pair.1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
split(((), ((), ())));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue