Write directly to the RETURN_PLACE in tuple_like_shim
This commit is contained in:
parent
e07aecde48
commit
7fd3c27345
@ -408,7 +408,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||||||
rcvr_field: Place<'tcx>,
|
rcvr_field: Place<'tcx>,
|
||||||
next: BasicBlock,
|
next: BasicBlock,
|
||||||
cleanup: BasicBlock,
|
cleanup: BasicBlock,
|
||||||
place: Place<'tcx>
|
dest: Place<'tcx>
|
||||||
) {
|
) {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||||||
self.block(vec![statement], TerminatorKind::Call {
|
self.block(vec![statement], TerminatorKind::Call {
|
||||||
func,
|
func,
|
||||||
args: vec![Operand::Move(ref_loc)],
|
args: vec![Operand::Move(ref_loc)],
|
||||||
destination: Some((place, next)),
|
destination: Some((dest, next)),
|
||||||
cleanup: Some(cleanup),
|
cleanup: Some(cleanup),
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
@ -633,12 +633,13 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||||||
|
|
||||||
let rcvr = Place::Local(Local::new(1+0)).deref();
|
let rcvr = Place::Local(Local::new(1+0)).deref();
|
||||||
|
|
||||||
let mut returns = Vec::new();
|
let mut previous_place = None;
|
||||||
|
let return_place = Place::Local(RETURN_PLACE);
|
||||||
for (i, ity) in tys.iter().enumerate() {
|
for (i, ity) in tys.iter().enumerate() {
|
||||||
let rcvr_field = rcvr.clone().field(Field::new(i), *ity);
|
let field = Field::new(i);
|
||||||
|
let rcvr_field = rcvr.clone().field(field, *ity);
|
||||||
|
|
||||||
let place = self.make_place(Mutability::Not, ity);
|
let place = return_place.clone().field(field, *ity);
|
||||||
returns.push(place.clone());
|
|
||||||
|
|
||||||
// BB #(2i)
|
// BB #(2i)
|
||||||
// `returns[i] = Clone::clone(&rcvr.i);`
|
// `returns[i] = Clone::clone(&rcvr.i);`
|
||||||
@ -648,34 +649,26 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||||||
rcvr_field,
|
rcvr_field,
|
||||||
BasicBlock::new(2 * i + 2),
|
BasicBlock::new(2 * i + 2),
|
||||||
BasicBlock::new(2 * i + 1),
|
BasicBlock::new(2 * i + 1),
|
||||||
place
|
place.clone()
|
||||||
);
|
);
|
||||||
|
|
||||||
// BB #(2i + 1) (cleanup)
|
// BB #(2i + 1) (cleanup)
|
||||||
if i == 0 {
|
if let Some(previous_place) = previous_place.take() {
|
||||||
// Nothing to drop, just resume.
|
|
||||||
self.block(vec![], TerminatorKind::Resume, true);
|
|
||||||
} else {
|
|
||||||
// Drop previous field and goto previous cleanup block.
|
// Drop previous field and goto previous cleanup block.
|
||||||
self.block(vec![], TerminatorKind::Drop {
|
self.block(vec![], TerminatorKind::Drop {
|
||||||
location: returns[i - 1].clone(),
|
location: previous_place,
|
||||||
target: BasicBlock::new(2 * i - 1),
|
target: BasicBlock::new(2 * i - 1),
|
||||||
unwind: None,
|
unwind: None,
|
||||||
}, true);
|
}, true);
|
||||||
|
} else {
|
||||||
|
// Nothing to drop, just resume.
|
||||||
|
self.block(vec![], TerminatorKind::Resume, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previous_place = Some(place);
|
||||||
}
|
}
|
||||||
|
|
||||||
// `return kind(returns[0], returns[1], ..., returns[tys.len() - 1]);`
|
self.block(vec![], TerminatorKind::Return, false);
|
||||||
let ret_statement = self.make_statement(
|
|
||||||
StatementKind::Assign(
|
|
||||||
Place::Local(RETURN_PLACE),
|
|
||||||
Rvalue::Aggregate(
|
|
||||||
box kind,
|
|
||||||
returns.into_iter().map(Operand::Move).collect()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
self.block(vec![ret_statement], TerminatorKind::Return, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user