Only compute mir_generator_witnesses query in drop_tracking_mir mode.
This commit is contained in:
parent
252741673b
commit
4db4860503
3 changed files with 19 additions and 18 deletions
|
@ -1415,7 +1415,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
if encode_opt {
|
if encode_opt {
|
||||||
record!(self.tables.optimized_mir[def_id.to_def_id()] <- tcx.optimized_mir(def_id));
|
record!(self.tables.optimized_mir[def_id.to_def_id()] <- tcx.optimized_mir(def_id));
|
||||||
|
|
||||||
if let DefKind::Generator = self.tcx.def_kind(def_id) {
|
if let DefKind::Generator = self.tcx.def_kind(def_id) && tcx.sess.opts.unstable_opts.drop_tracking_mir {
|
||||||
record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- tcx.mir_generator_witnesses(def_id));
|
record!(self.tables.mir_generator_witnesses[def_id.to_def_id()] <- tcx.mir_generator_witnesses(def_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1390,6 +1390,7 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) -> GeneratorLayout<'tcx> {
|
) -> GeneratorLayout<'tcx> {
|
||||||
|
assert!(tcx.sess.opts.unstable_opts.drop_tracking_mir);
|
||||||
let def_id = def_id.expect_local();
|
let def_id = def_id.expect_local();
|
||||||
|
|
||||||
let (body, _) = tcx.mir_promoted(ty::WithOptConstParam::unknown(def_id));
|
let (body, _) = tcx.mir_promoted(ty::WithOptConstParam::unknown(def_id));
|
||||||
|
@ -1400,15 +1401,8 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
|
||||||
let gen_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty;
|
let gen_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty;
|
||||||
|
|
||||||
// Get the interior types and substs which typeck computed
|
// Get the interior types and substs which typeck computed
|
||||||
let (upvars, interior, movable) = match *gen_ty.kind() {
|
let movable = match *gen_ty.kind() {
|
||||||
ty::Generator(_, substs, movability) => {
|
ty::Generator(_, _, movability) => movability == hir::Movability::Movable,
|
||||||
let substs = substs.as_generator();
|
|
||||||
(
|
|
||||||
substs.upvar_tys().collect::<Vec<_>>(),
|
|
||||||
substs.witness(),
|
|
||||||
movability == hir::Movability::Movable,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => span_bug!(body.span, "unexpected generator type {}", gen_ty),
|
_ => span_bug!(body.span, "unexpected generator type {}", gen_ty),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1422,11 +1416,7 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
|
||||||
// `storage_liveness` tells us which locals have live storage at suspension points
|
// `storage_liveness` tells us which locals have live storage at suspension points
|
||||||
let (_, generator_layout, _) = compute_layout(tcx, liveness_info, body);
|
let (_, generator_layout, _) = compute_layout(tcx, liveness_info, body);
|
||||||
|
|
||||||
if tcx.sess.opts.unstable_opts.drop_tracking_mir {
|
check_suspend_tys(tcx, &generator_layout, &body);
|
||||||
check_suspend_tys(tcx, &generator_layout, &body);
|
|
||||||
} else {
|
|
||||||
sanitize_witness(tcx, body, interior, upvars, &generator_layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
generator_layout
|
generator_layout
|
||||||
}
|
}
|
||||||
|
@ -1444,10 +1434,15 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
|
||||||
let gen_ty = body.local_decls.raw[1].ty;
|
let gen_ty = body.local_decls.raw[1].ty;
|
||||||
|
|
||||||
// Get the discriminant type and substs which typeck computed
|
// Get the discriminant type and substs which typeck computed
|
||||||
let (discr_ty, movable) = match *gen_ty.kind() {
|
let (discr_ty, upvars, interior, movable) = match *gen_ty.kind() {
|
||||||
ty::Generator(_, substs, movability) => {
|
ty::Generator(_, substs, movability) => {
|
||||||
let substs = substs.as_generator();
|
let substs = substs.as_generator();
|
||||||
(substs.discr_ty(tcx), movability == hir::Movability::Movable)
|
(
|
||||||
|
substs.discr_ty(tcx),
|
||||||
|
substs.upvar_tys().collect::<Vec<_>>(),
|
||||||
|
substs.witness(),
|
||||||
|
movability == hir::Movability::Movable,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
|
@ -1524,6 +1519,12 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
|
||||||
// `storage_liveness` tells us which locals have live storage at suspension points
|
// `storage_liveness` tells us which locals have live storage at suspension points
|
||||||
let (remap, layout, storage_liveness) = compute_layout(tcx, liveness_info, body);
|
let (remap, layout, storage_liveness) = compute_layout(tcx, liveness_info, body);
|
||||||
|
|
||||||
|
if tcx.sess.opts.unstable_opts.validate_mir
|
||||||
|
&& !tcx.sess.opts.unstable_opts.drop_tracking_mir
|
||||||
|
{
|
||||||
|
sanitize_witness(tcx, body, interior, upvars, &layout);
|
||||||
|
}
|
||||||
|
|
||||||
let can_return = can_return(tcx, body, tcx.param_env(body.source.def_id()));
|
let can_return = can_return(tcx, body, tcx.param_env(body.source.def_id()));
|
||||||
|
|
||||||
// Run the transformation which converts Places from Local to generator struct
|
// Run the transformation which converts Places from Local to generator struct
|
||||||
|
|
|
@ -426,7 +426,7 @@ fn mir_drops_elaborated_and_const_checked(
|
||||||
return tcx.mir_drops_elaborated_and_const_checked(def);
|
return tcx.mir_drops_elaborated_and_const_checked(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
if tcx.generator_kind(def.did).is_some() {
|
if tcx.generator_kind(def.did).is_some() && tcx.sess.opts.unstable_opts.drop_tracking_mir {
|
||||||
tcx.ensure().mir_generator_witnesses(def.did);
|
tcx.ensure().mir_generator_witnesses(def.did);
|
||||||
}
|
}
|
||||||
let mir_borrowck = tcx.mir_borrowck_opt_const_arg(def);
|
let mir_borrowck = tcx.mir_borrowck_opt_const_arg(def);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue