@@ -9,24 +9,22 @@ use rustc::ty::{self, Ty, TyCtxt};
99use rustc_hir:: def_id:: DefId ;
1010use rustc_index:: bit_set:: BitSet ;
1111
12+ use crate :: dataflow:: generic:: { Analysis , Results , ResultsCursor } ;
1213use crate :: dataflow:: move_paths:: { HasMoveData , MoveData } ;
1314use crate :: dataflow:: move_paths:: { LookupResult , MovePathIndex } ;
14- use crate :: dataflow:: BitDenotation ;
15- use crate :: dataflow:: DataflowResults ;
16- use crate :: dataflow:: DataflowResultsCursor ;
1715use crate :: dataflow:: IndirectlyMutableLocals ;
1816use crate :: dataflow:: MoveDataParamEnv ;
1917use crate :: dataflow:: { do_dataflow, DebugFormatted } ;
2018use crate :: dataflow:: {
2119 DefinitelyInitializedPlaces , MaybeInitializedPlaces , MaybeUninitializedPlaces ,
2220} ;
2321
24- use crate :: dataflow:: has_rustc_mir_with;
25-
2622pub struct SanityCheck ;
2723
2824impl < ' tcx > MirPass < ' tcx > for SanityCheck {
2925 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , src : MirSource < ' tcx > , body : & mut BodyAndCache < ' tcx > ) {
26+ use crate :: dataflow:: has_rustc_mir_with;
27+
3028 let def_id = src. def_id ( ) ;
3129 if !tcx. has_attr ( def_id, sym:: rustc_mir) {
3230 debug ! ( "skipping rustc_peek::SanityCheck on {}" , tcx. def_path_str( def_id) ) ;
@@ -40,34 +38,17 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
4038 let move_data = MoveData :: gather_moves ( body, tcx, param_env) . unwrap ( ) ;
4139 let mdpe = MoveDataParamEnv { move_data : move_data, param_env : param_env } ;
4240 let dead_unwinds = BitSet :: new_empty ( body. basic_blocks ( ) . len ( ) ) ;
43- let flow_inits = do_dataflow (
44- tcx,
45- body,
46- def_id,
47- & attributes,
48- & dead_unwinds,
49- MaybeInitializedPlaces :: new ( tcx, body, & mdpe) ,
50- |bd, i| DebugFormatted :: new ( & bd. move_data ( ) . move_paths [ i] ) ,
51- ) ;
52- let flow_uninits = do_dataflow (
53- tcx,
54- body,
55- def_id,
56- & attributes,
57- & dead_unwinds,
58- MaybeUninitializedPlaces :: new ( tcx, body, & mdpe) ,
59- |bd, i| DebugFormatted :: new ( & bd. move_data ( ) . move_paths [ i] ) ,
60- ) ;
61- let flow_def_inits = do_dataflow (
62- tcx,
63- body,
64- def_id,
65- & attributes,
66- & dead_unwinds,
67- DefinitelyInitializedPlaces :: new ( tcx, body, & mdpe) ,
68- |bd, i| DebugFormatted :: new ( & bd. move_data ( ) . move_paths [ i] ) ,
69- ) ;
70- let flow_indirectly_mut = do_dataflow (
41+
42+ let flow_inits = MaybeInitializedPlaces :: new ( tcx, body, & mdpe)
43+ . into_engine ( tcx, body, def_id)
44+ . iterate_to_fixpoint ( ) ;
45+ let flow_uninits = MaybeUninitializedPlaces :: new ( tcx, body, & mdpe)
46+ . into_engine ( tcx, body, def_id)
47+ . iterate_to_fixpoint ( ) ;
48+ let flow_def_inits = DefinitelyInitializedPlaces :: new ( tcx, body, & mdpe)
49+ . into_engine ( tcx, body, def_id)
50+ . iterate_to_fixpoint ( ) ;
51+ let _flow_indirectly_mut = do_dataflow (
7152 tcx,
7253 body,
7354 def_id,
@@ -86,9 +67,12 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
8667 if has_rustc_mir_with ( & attributes, sym:: rustc_peek_definite_init) . is_some ( ) {
8768 sanity_check_via_rustc_peek ( tcx, body, def_id, & attributes, & flow_def_inits) ;
8869 }
70+ // FIXME: Uncomment these as analyses are migrated to the new framework
71+ /*
8972 if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() {
9073 sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_indirectly_mut);
9174 }
75+ */
9276 if has_rustc_mir_with ( & attributes, sym:: stop_after_dataflow) . is_some ( ) {
9377 tcx. sess . fatal ( "stop_after_dataflow ended compilation" ) ;
9478 }
@@ -111,18 +95,18 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
11195/// (If there are any calls to `rustc_peek` that do not match the
11296/// expression form above, then that emits an error as well, but those
11397/// errors are not intended to be used for unit tests.)
114- pub fn sanity_check_via_rustc_peek < ' tcx , O > (
98+ pub fn sanity_check_via_rustc_peek < ' tcx , A > (
11599 tcx : TyCtxt < ' tcx > ,
116100 body : & Body < ' tcx > ,
117101 def_id : DefId ,
118102 _attributes : & [ ast:: Attribute ] ,
119- results : & DataflowResults < ' tcx , O > ,
103+ results : & Results < ' tcx , A > ,
120104) where
121- O : RustcPeekAt < ' tcx > ,
105+ A : RustcPeekAt < ' tcx > ,
122106{
123107 debug ! ( "sanity_check_via_rustc_peek def_id: {:?}" , def_id) ;
124108
125- let mut cursor = DataflowResultsCursor :: new ( results , body ) ;
109+ let mut cursor = ResultsCursor :: new ( body , results ) ;
126110
127111 let peek_calls = body. basic_blocks ( ) . iter_enumerated ( ) . filter_map ( |( bb, block_data) | {
128112 PeekCall :: from_terminator ( tcx, block_data. terminator ( ) ) . map ( |call| ( bb, block_data, call) )
@@ -153,9 +137,9 @@ pub fn sanity_check_via_rustc_peek<'tcx, O>(
153137 | ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Move ( place) ) )
154138 | ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Copy ( place) ) ) => {
155139 let loc = Location { block : bb, statement_index } ;
156- cursor. seek ( loc) ;
140+ cursor. seek_before ( loc) ;
157141 let state = cursor. get ( ) ;
158- results. operator ( ) . peek_at ( tcx, place, state, call) ;
142+ results. analysis . peek_at ( tcx, place, state, call) ;
159143 }
160144
161145 _ => {
@@ -255,7 +239,7 @@ impl PeekCall {
255239 }
256240}
257241
258- pub trait RustcPeekAt < ' tcx > : BitDenotation < ' tcx > {
242+ pub trait RustcPeekAt < ' tcx > : Analysis < ' tcx > {
259243 fn peek_at (
260244 & self ,
261245 tcx : TyCtxt < ' tcx > ,
@@ -265,9 +249,9 @@ pub trait RustcPeekAt<'tcx>: BitDenotation<'tcx> {
265249 ) ;
266250}
267251
268- impl < ' tcx , O > RustcPeekAt < ' tcx > for O
252+ impl < ' tcx , A > RustcPeekAt < ' tcx > for A
269253where
270- O : BitDenotation < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
254+ A : Analysis < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
271255{
272256 fn peek_at (
273257 & self ,
@@ -292,6 +276,7 @@ where
292276 }
293277}
294278
279+ /* FIXME: Add this back once `IndirectlyMutableLocals` uses the new dataflow framework.
295280impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
296281 fn peek_at(
297282 &self,
@@ -313,3 +298,4 @@ impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
313298 }
314299 }
315300}
301+ */
0 commit comments