提交 f2c14689 编写于 作者: J Jonas Schievink

Add resume arg place to `Yield` MIR terminator

上级 2101a1fe
......@@ -1120,6 +1120,8 @@ pub enum TerminatorKind<'tcx> {
value: Operand<'tcx>,
/// Where to resume to.
resume: BasicBlock,
/// The place to store the resume argument in.
resume_arg: Place<'tcx>,
/// Cleanup to be done if the generator is dropped at this suspend point.
drop: Option<BasicBlock>,
},
......@@ -2645,9 +2647,12 @@ fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
target,
unwind,
},
Yield { ref value, resume, drop } => {
Yield { value: value.fold_with(folder), resume: resume, drop: drop }
}
Yield { ref value, resume, ref resume_arg, drop } => Yield {
value: value.fold_with(folder),
resume,
resume_arg: resume_arg.fold_with(folder),
drop,
},
Call { ref func, ref args, ref destination, cleanup, from_hir_call } => {
let dest =
destination.as_ref().map(|&(ref loc, dest)| (loc.fold_with(folder), dest));
......
......@@ -516,8 +516,14 @@ fn super_terminator_kind(&mut self,
TerminatorKind::Yield {
value,
resume: _,
resume_arg,
drop: _,
} => {
self.visit_place(
resume_arg,
PlaceContext::MutatingUse(MutatingUseContext::Store),
source_location,
);
self.visit_operand(value, source_location);
}
......
......@@ -159,7 +159,7 @@ fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Locat
self.consume_operand(location, index);
}
}
TerminatorKind::Yield { ref value, resume, drop: _ } => {
TerminatorKind::Yield { ref value, resume, resume_arg, drop: _ } => {
self.consume_operand(location, value);
// Invalidate all borrows of local places
......@@ -170,6 +170,8 @@ fn visit_terminator_kind(&mut self, kind: &TerminatorKind<'tcx>, location: Locat
self.all_facts.invalidates.push((resume, i));
}
}
self.mutate_place(location, resume_arg, Deep, JustWrite);
}
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
// Invalidate all borrows of local places
......
......@@ -684,7 +684,7 @@ fn visit_terminator_entry(
}
}
TerminatorKind::Yield { ref value, resume: _, drop: _ } => {
TerminatorKind::Yield { ref value, resume: _, ref resume_arg, drop: _ } => {
self.consume_operand(loc, (value, span), flow_state);
if self.movable_generator {
......@@ -697,6 +697,8 @@ fn visit_terminator_entry(
}
});
}
self.mutate_place(loc, (resume_arg, span), Deep, JustWrite, flow_state);
}
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
......
......@@ -581,9 +581,11 @@ fn compute_inputs_and_output(
DefiningTy::Generator(def_id, substs, movability) => {
assert_eq!(self.mir_def_id, def_id);
let resume_ty = substs.as_generator().resume_ty(def_id, tcx);
let output = substs.as_generator().return_ty(def_id, tcx);
let generator_ty = tcx.mk_generator(def_id, substs, movability);
let inputs_and_output = self.infcx.tcx.intern_type_list(&[generator_ty, output]);
let inputs_and_output =
self.infcx.tcx.intern_type_list(&[generator_ty, resume_ty, output]);
ty::Binder::dummy(inputs_and_output)
}
......
......@@ -380,7 +380,9 @@ fn gather_terminator(&mut self, term: &Terminator<'tcx>) {
self.gather_operand(discr);
}
TerminatorKind::Yield { ref value, .. } => {
TerminatorKind::Yield { ref value, resume_arg: ref place, .. } => {
self.create_move_path(place);
self.gather_init(place.as_ref(), InitKind::Deep);
self.gather_operand(value);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册