@@ -9,24 +9,22 @@ use rustc::ty::{self, Ty, TyCtxt};
9
9
use rustc_hir:: def_id:: DefId ;
10
10
use rustc_index:: bit_set:: BitSet ;
11
11
12
+ use crate :: dataflow:: generic:: { Analysis , Results , ResultsCursor } ;
12
13
use crate :: dataflow:: move_paths:: { HasMoveData , MoveData } ;
13
14
use crate :: dataflow:: move_paths:: { LookupResult , MovePathIndex } ;
14
- use crate :: dataflow:: BitDenotation ;
15
- use crate :: dataflow:: DataflowResults ;
16
- use crate :: dataflow:: DataflowResultsCursor ;
17
15
use crate :: dataflow:: IndirectlyMutableLocals ;
18
16
use crate :: dataflow:: MoveDataParamEnv ;
19
17
use crate :: dataflow:: { do_dataflow, DebugFormatted } ;
20
18
use crate :: dataflow:: {
21
19
DefinitelyInitializedPlaces , MaybeInitializedPlaces , MaybeUninitializedPlaces ,
22
20
} ;
23
21
24
- use crate :: dataflow:: has_rustc_mir_with;
25
-
26
22
pub struct SanityCheck ;
27
23
28
24
impl < ' tcx > MirPass < ' tcx > for SanityCheck {
29
25
fn run_pass ( & self , tcx : TyCtxt < ' tcx > , src : MirSource < ' tcx > , body : & mut BodyAndCache < ' tcx > ) {
26
+ use crate :: dataflow:: has_rustc_mir_with;
27
+
30
28
let def_id = src. def_id ( ) ;
31
29
if !tcx. has_attr ( def_id, sym:: rustc_mir) {
32
30
debug ! ( "skipping rustc_peek::SanityCheck on {}" , tcx. def_path_str( def_id) ) ;
@@ -40,34 +38,17 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
40
38
let move_data = MoveData :: gather_moves ( body, tcx, param_env) . unwrap ( ) ;
41
39
let mdpe = MoveDataParamEnv { move_data : move_data, param_env : param_env } ;
42
40
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 (
71
52
tcx,
72
53
body,
73
54
def_id,
@@ -86,9 +67,12 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
86
67
if has_rustc_mir_with ( & attributes, sym:: rustc_peek_definite_init) . is_some ( ) {
87
68
sanity_check_via_rustc_peek ( tcx, body, def_id, & attributes, & flow_def_inits) ;
88
69
}
70
+ // FIXME: Uncomment these as analyses are migrated to the new framework
71
+ /*
89
72
if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() {
90
73
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_indirectly_mut);
91
74
}
75
+ */
92
76
if has_rustc_mir_with ( & attributes, sym:: stop_after_dataflow) . is_some ( ) {
93
77
tcx. sess . fatal ( "stop_after_dataflow ended compilation" ) ;
94
78
}
@@ -111,18 +95,18 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
111
95
/// (If there are any calls to `rustc_peek` that do not match the
112
96
/// expression form above, then that emits an error as well, but those
113
97
/// 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 > (
115
99
tcx : TyCtxt < ' tcx > ,
116
100
body : & Body < ' tcx > ,
117
101
def_id : DefId ,
118
102
_attributes : & [ ast:: Attribute ] ,
119
- results : & DataflowResults < ' tcx , O > ,
103
+ results : & Results < ' tcx , A > ,
120
104
) where
121
- O : RustcPeekAt < ' tcx > ,
105
+ A : RustcPeekAt < ' tcx > ,
122
106
{
123
107
debug ! ( "sanity_check_via_rustc_peek def_id: {:?}" , def_id) ;
124
108
125
- let mut cursor = DataflowResultsCursor :: new ( results , body ) ;
109
+ let mut cursor = ResultsCursor :: new ( body , results ) ;
126
110
127
111
let peek_calls = body. basic_blocks ( ) . iter_enumerated ( ) . filter_map ( |( bb, block_data) | {
128
112
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>(
153
137
| ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Move ( place) ) )
154
138
| ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Copy ( place) ) ) => {
155
139
let loc = Location { block : bb, statement_index } ;
156
- cursor. seek ( loc) ;
140
+ cursor. seek_before ( loc) ;
157
141
let state = cursor. get ( ) ;
158
- results. operator ( ) . peek_at ( tcx, place, state, call) ;
142
+ results. analysis . peek_at ( tcx, place, state, call) ;
159
143
}
160
144
161
145
_ => {
@@ -255,7 +239,7 @@ impl PeekCall {
255
239
}
256
240
}
257
241
258
- pub trait RustcPeekAt < ' tcx > : BitDenotation < ' tcx > {
242
+ pub trait RustcPeekAt < ' tcx > : Analysis < ' tcx > {
259
243
fn peek_at (
260
244
& self ,
261
245
tcx : TyCtxt < ' tcx > ,
@@ -265,9 +249,9 @@ pub trait RustcPeekAt<'tcx>: BitDenotation<'tcx> {
265
249
) ;
266
250
}
267
251
268
- impl < ' tcx , O > RustcPeekAt < ' tcx > for O
252
+ impl < ' tcx , A > RustcPeekAt < ' tcx > for A
269
253
where
270
- O : BitDenotation < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
254
+ A : Analysis < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
271
255
{
272
256
fn peek_at (
273
257
& self ,
@@ -292,6 +276,7 @@ where
292
276
}
293
277
}
294
278
279
+ /* FIXME: Add this back once `IndirectlyMutableLocals` uses the new dataflow framework.
295
280
impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
296
281
fn peek_at(
297
282
&self,
@@ -313,3 +298,4 @@ impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
313
298
}
314
299
}
315
300
}
301
+ */
0 commit comments