Skip to content

Commit 7c7c9b3

Browse files
Make rustc_peek use the unified dataflow framework
1 parent 32c3590 commit 7c7c9b3

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/librustc_mir/transform/rustc_peek.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ use rustc::mir::{self, Body, BodyAndCache, Location, Local};
99
use rustc_index::bit_set::BitSet;
1010
use crate::transform::{MirPass, MirSource};
1111

12+
use crate::dataflow::generic::{Analysis, Results, ResultsCursor};
1213
use crate::dataflow::{do_dataflow, DebugFormatted};
1314
use crate::dataflow::MoveDataParamEnv;
14-
use crate::dataflow::BitDenotation;
15-
use crate::dataflow::DataflowResults;
16-
use crate::dataflow::DataflowResultsCursor;
1715
use crate::dataflow::{
1816
DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces
1917
};
2018
use crate::dataflow::IndirectlyMutableLocals;
2119
use crate::dataflow::move_paths::{MovePathIndex, LookupResult};
2220
use crate::dataflow::move_paths::{HasMoveData, MoveData};
2321

24-
use crate::dataflow::has_rustc_mir_with;
2522

2623
pub struct SanityCheck;
2724

2825
impl<'tcx> MirPass<'tcx> for SanityCheck {
26+
#[allow(unused)]
2927
fn run_pass(&self, tcx: TyCtxt<'tcx>, src: MirSource<'tcx>, body: &mut BodyAndCache<'tcx>) {
28+
use crate::dataflow::has_rustc_mir_with;
29+
3030
let def_id = src.def_id();
3131
if !tcx.has_attr(def_id, sym::rustc_mir) {
3232
debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id));
@@ -57,6 +57,8 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
5757
IndirectlyMutableLocals::new(tcx, body, param_env),
5858
|_, i| DebugFormatted::new(&i));
5959

60+
// FIXME: add these back as dataflow analyses are migrated
61+
/*
6062
if has_rustc_mir_with(&attributes, sym::rustc_peek_maybe_init).is_some() {
6163
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_inits);
6264
}
@@ -82,6 +84,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
8284
if has_rustc_mir_with(&attributes, sym::stop_after_dataflow).is_some() {
8385
tcx.sess.fatal("stop_after_dataflow ended compilation");
8486
}
87+
*/
8588
}
8689
}
8790

@@ -101,16 +104,16 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
101104
/// (If there are any calls to `rustc_peek` that do not match the
102105
/// expression form above, then that emits an error as well, but those
103106
/// errors are not intended to be used for unit tests.)
104-
pub fn sanity_check_via_rustc_peek<'tcx, O>(
107+
pub fn sanity_check_via_rustc_peek<'tcx, A>(
105108
tcx: TyCtxt<'tcx>,
106109
body: &Body<'tcx>,
107110
def_id: DefId,
108111
_attributes: &[ast::Attribute],
109-
results: &DataflowResults<'tcx, O>,
110-
) where O: RustcPeekAt<'tcx> {
112+
results: &Results<'tcx, A>,
113+
) where A: RustcPeekAt<'tcx> {
111114
debug!("sanity_check_via_rustc_peek def_id: {:?}", def_id);
112115

113-
let mut cursor = DataflowResultsCursor::new(results, body);
116+
let mut cursor = ResultsCursor::new(body, results);
114117

115118
let peek_calls = body
116119
.basic_blocks()
@@ -144,9 +147,9 @@ pub fn sanity_check_via_rustc_peek<'tcx, O>(
144147
| (PeekCallKind::ByVal, mir::Rvalue::Use(mir::Operand::Copy(place)))
145148
=> {
146149
let loc = Location { block: bb, statement_index };
147-
cursor.seek(loc);
150+
cursor.seek_before(loc);
148151
let state = cursor.get();
149-
results.operator().peek_at(tcx, place, state, call);
152+
results.analysis.peek_at(tcx, place, state, call);
150153
}
151154

152155
_ => {
@@ -250,7 +253,7 @@ impl PeekCall {
250253
}
251254
}
252255

253-
pub trait RustcPeekAt<'tcx>: BitDenotation<'tcx> {
256+
pub trait RustcPeekAt<'tcx>: Analysis<'tcx> {
254257
fn peek_at(
255258
&self,
256259
tcx: TyCtxt<'tcx>,
@@ -260,8 +263,8 @@ pub trait RustcPeekAt<'tcx>: BitDenotation<'tcx> {
260263
);
261264
}
262265

263-
impl<'tcx, O> RustcPeekAt<'tcx> for O
264-
where O: BitDenotation<'tcx, Idx = MovePathIndex> + HasMoveData<'tcx>,
266+
impl<'tcx, A> RustcPeekAt<'tcx> for A
267+
where A: Analysis<'tcx, Idx = MovePathIndex> + HasMoveData<'tcx>,
265268
{
266269
fn peek_at(
267270
&self,
@@ -287,6 +290,7 @@ impl<'tcx, O> RustcPeekAt<'tcx> for O
287290
}
288291
}
289292

293+
/* FIXME: Add this back once `IndirectlyMutableLocals` uses the new dataflow framework.
290294
impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
291295
fn peek_at(
292296
&self,
@@ -308,3 +312,4 @@ impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
308312
}
309313
}
310314
}
315+
*/

0 commit comments

Comments
 (0)