Skip to content

Commit 9972502

Browse files
Reenable peek test for indirect mutation analysis
This uses the new `MaybeMutBorrowedLocals` pass but we keep the `rustc_peek_indirectly_mutable` since the two are interchangable except when inspecting a local after it has been marked `StorageDead`.
1 parent 34783b7 commit 9972502

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

src/librustc_mir/transform/rustc_peek.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ use rustc_index::bit_set::BitSet;
1212
use crate::dataflow::generic::{Analysis, Results, ResultsCursor};
1313
use crate::dataflow::move_paths::{HasMoveData, MoveData};
1414
use crate::dataflow::move_paths::{LookupResult, MovePathIndex};
15-
use crate::dataflow::IndirectlyMutableLocals;
15+
use crate::dataflow::MaybeMutBorrowedLocals;
1616
use crate::dataflow::MoveDataParamEnv;
17-
use crate::dataflow::{do_dataflow, DebugFormatted};
1817
use crate::dataflow::{
1918
DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
2019
};
@@ -24,7 +23,6 @@ pub struct SanityCheck;
2423
impl<'tcx> MirPass<'tcx> for SanityCheck {
2524
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
2625
use crate::dataflow::has_rustc_mir_with;
27-
2826
let def_id = src.def_id();
2927
if !tcx.has_attr(def_id, sym::rustc_mir) {
3028
debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id));
@@ -37,7 +35,6 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
3735
let param_env = tcx.param_env(def_id);
3836
let move_data = MoveData::gather_moves(body, tcx, param_env).unwrap();
3937
let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env };
40-
let dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
4138

4239
let flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe)
4340
.into_engine(tcx, body, def_id)
@@ -48,15 +45,9 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
4845
let flow_def_inits = DefinitelyInitializedPlaces::new(tcx, body, &mdpe)
4946
.into_engine(tcx, body, def_id)
5047
.iterate_to_fixpoint();
51-
let _flow_indirectly_mut = do_dataflow(
52-
tcx,
53-
body,
54-
def_id,
55-
&attributes,
56-
&dead_unwinds,
57-
IndirectlyMutableLocals::new(tcx, body, param_env),
58-
|_, i| DebugFormatted::new(&i),
59-
);
48+
let flow_mut_borrowed = MaybeMutBorrowedLocals::new_mut_only(tcx, body, param_env)
49+
.into_engine(tcx, body, def_id)
50+
.iterate_to_fixpoint();
6051

6152
if has_rustc_mir_with(&attributes, sym::rustc_peek_maybe_init).is_some() {
6253
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_inits);
@@ -67,12 +58,9 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
6758
if has_rustc_mir_with(&attributes, sym::rustc_peek_definite_init).is_some() {
6859
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_def_inits);
6960
}
70-
// FIXME: Uncomment these as analyses are migrated to the new framework
71-
/*
7261
if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() {
73-
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_indirectly_mut);
62+
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_mut_borrowed);
7463
}
75-
*/
7664
if has_rustc_mir_with(&attributes, sym::stop_after_dataflow).is_some() {
7765
tcx.sess.fatal("stop_after_dataflow ended compilation");
7866
}
@@ -276,8 +264,7 @@ where
276264
}
277265
}
278266

279-
/* FIXME: Add this back once `IndirectlyMutableLocals` uses the new dataflow framework.
280-
impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
267+
impl<'tcx> RustcPeekAt<'tcx> for MaybeMutBorrowedLocals<'_, 'tcx> {
281268
fn peek_at(
282269
&self,
283270
tcx: TyCtxt<'tcx>,
@@ -298,4 +285,3 @@ impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
298285
}
299286
}
300287
}
301-
*/

0 commit comments

Comments
 (0)