@@ -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 , Engine , 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,25 @@ 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 (
41
+
42
+ let flow_inits =
43
+ Engine :: new_gen_kill ( tcx, body, def_id, MaybeInitializedPlaces :: new ( tcx, body, & mdpe) )
44
+ . iterate_to_fixpoint ( ) ;
45
+ let flow_uninits = Engine :: new_gen_kill (
53
46
tcx,
54
47
body,
55
48
def_id,
56
- & attributes,
57
- & dead_unwinds,
58
49
MaybeUninitializedPlaces :: new ( tcx, body, & mdpe) ,
59
- |bd , i| DebugFormatted :: new ( & bd . move_data ( ) . move_paths [ i ] ) ,
60
- ) ;
61
- let flow_def_inits = do_dataflow (
50
+ )
51
+ . iterate_to_fixpoint ( ) ;
52
+ let flow_def_inits = Engine :: new_gen_kill (
62
53
tcx,
63
54
body,
64
55
def_id,
65
- & attributes,
66
- & dead_unwinds,
67
56
DefinitelyInitializedPlaces :: new ( tcx, body, & mdpe) ,
68
- |bd , i| DebugFormatted :: new ( & bd . move_data ( ) . move_paths [ i ] ) ,
69
- ) ;
70
- let flow_indirectly_mut = do_dataflow (
57
+ )
58
+ . iterate_to_fixpoint ( ) ;
59
+ let _flow_indirectly_mut = do_dataflow (
71
60
tcx,
72
61
body,
73
62
def_id,
@@ -86,9 +75,12 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
86
75
if has_rustc_mir_with ( & attributes, sym:: rustc_peek_definite_init) . is_some ( ) {
87
76
sanity_check_via_rustc_peek ( tcx, body, def_id, & attributes, & flow_def_inits) ;
88
77
}
78
+ // FIXME: Uncomment these as analyses are migrated to the new framework
79
+ /*
89
80
if has_rustc_mir_with(&attributes, sym::rustc_peek_indirectly_mutable).is_some() {
90
81
sanity_check_via_rustc_peek(tcx, body, def_id, &attributes, &flow_indirectly_mut);
91
82
}
83
+ */
92
84
if has_rustc_mir_with ( & attributes, sym:: stop_after_dataflow) . is_some ( ) {
93
85
tcx. sess . fatal ( "stop_after_dataflow ended compilation" ) ;
94
86
}
@@ -111,18 +103,18 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
111
103
/// (If there are any calls to `rustc_peek` that do not match the
112
104
/// expression form above, then that emits an error as well, but those
113
105
/// errors are not intended to be used for unit tests.)
114
- pub fn sanity_check_via_rustc_peek < ' tcx , O > (
106
+ pub fn sanity_check_via_rustc_peek < ' tcx , A > (
115
107
tcx : TyCtxt < ' tcx > ,
116
108
body : & Body < ' tcx > ,
117
109
def_id : DefId ,
118
110
_attributes : & [ ast:: Attribute ] ,
119
- results : & DataflowResults < ' tcx , O > ,
111
+ results : & Results < ' tcx , A > ,
120
112
) where
121
- O : RustcPeekAt < ' tcx > ,
113
+ A : RustcPeekAt < ' tcx > ,
122
114
{
123
115
debug ! ( "sanity_check_via_rustc_peek def_id: {:?}" , def_id) ;
124
116
125
- let mut cursor = DataflowResultsCursor :: new ( results , body ) ;
117
+ let mut cursor = ResultsCursor :: new ( body , results ) ;
126
118
127
119
let peek_calls = body. basic_blocks ( ) . iter_enumerated ( ) . filter_map ( |( bb, block_data) | {
128
120
PeekCall :: from_terminator ( tcx, block_data. terminator ( ) ) . map ( |call| ( bb, block_data, call) )
@@ -153,9 +145,9 @@ pub fn sanity_check_via_rustc_peek<'tcx, O>(
153
145
| ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Move ( place) ) )
154
146
| ( PeekCallKind :: ByVal , mir:: Rvalue :: Use ( mir:: Operand :: Copy ( place) ) ) => {
155
147
let loc = Location { block : bb, statement_index } ;
156
- cursor. seek ( loc) ;
148
+ cursor. seek_before ( loc) ;
157
149
let state = cursor. get ( ) ;
158
- results. operator ( ) . peek_at ( tcx, place, state, call) ;
150
+ results. analysis . peek_at ( tcx, place, state, call) ;
159
151
}
160
152
161
153
_ => {
@@ -255,7 +247,7 @@ impl PeekCall {
255
247
}
256
248
}
257
249
258
- pub trait RustcPeekAt < ' tcx > : BitDenotation < ' tcx > {
250
+ pub trait RustcPeekAt < ' tcx > : Analysis < ' tcx > {
259
251
fn peek_at (
260
252
& self ,
261
253
tcx : TyCtxt < ' tcx > ,
@@ -265,9 +257,9 @@ pub trait RustcPeekAt<'tcx>: BitDenotation<'tcx> {
265
257
) ;
266
258
}
267
259
268
- impl < ' tcx , O > RustcPeekAt < ' tcx > for O
260
+ impl < ' tcx , A > RustcPeekAt < ' tcx > for A
269
261
where
270
- O : BitDenotation < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
262
+ A : Analysis < ' tcx , Idx = MovePathIndex > + HasMoveData < ' tcx > ,
271
263
{
272
264
fn peek_at (
273
265
& self ,
@@ -292,6 +284,7 @@ where
292
284
}
293
285
}
294
286
287
+ /* FIXME: Add this back once `IndirectlyMutableLocals` uses the new dataflow framework.
295
288
impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
296
289
fn peek_at(
297
290
&self,
@@ -313,3 +306,4 @@ impl<'tcx> RustcPeekAt<'tcx> for IndirectlyMutableLocals<'_, 'tcx> {
313
306
}
314
307
}
315
308
}
309
+ */
0 commit comments