71
71
}
72
72
}
73
73
74
- pub enum Blocks {
75
- /// Consider all MIR blocks
76
- All ,
77
- /// Consider only the MIR blocks reachable from the start
78
- Reachable ,
79
- }
80
-
81
74
/// A solver for dataflow problems.
82
75
pub struct Engine < ' a , ' tcx , A >
83
76
where
97
90
// performance in practice. I've tried a few ways to avoid this, but they have downsides. See
98
91
// the message for the commit that added this FIXME for more information.
99
92
apply_trans_for_block : Option < Box < dyn Fn ( BasicBlock , & mut A :: Domain ) > > ,
100
- blocks : Blocks ,
101
93
}
102
94
103
95
impl < ' a , ' tcx , A , D , T > Engine < ' a , ' tcx , A >
@@ -107,18 +99,13 @@ where
107
99
T : Idx ,
108
100
{
109
101
/// Creates a new `Engine` to solve a gen-kill dataflow problem.
110
- pub fn new_gen_kill (
111
- tcx : TyCtxt < ' tcx > ,
112
- body : & ' a mir:: Body < ' tcx > ,
113
- analysis : A ,
114
- blocks : Blocks ,
115
- ) -> Self {
102
+ pub fn new_gen_kill ( tcx : TyCtxt < ' tcx > , body : & ' a mir:: Body < ' tcx > , analysis : A ) -> Self {
116
103
// If there are no back-edges in the control-flow graph, we only ever need to apply the
117
104
// transfer function for each block exactly once (assuming that we process blocks in RPO).
118
105
//
119
106
// In this case, there's no need to compute the block transfer functions ahead of time.
120
107
if !body. basic_blocks . is_cfg_cyclic ( ) {
121
- return Self :: new ( tcx, body, analysis, None , blocks ) ;
108
+ return Self :: new ( tcx, body, analysis, None ) ;
122
109
}
123
110
124
111
// Otherwise, compute and store the cumulative transfer function for each block.
@@ -135,7 +122,7 @@ where
135
122
trans_for_block[ bb] . apply ( state) ;
136
123
} ) ;
137
124
138
- Self :: new ( tcx, body, analysis, Some ( apply_trans as Box < _ > ) , blocks )
125
+ Self :: new ( tcx, body, analysis, Some ( apply_trans as Box < _ > ) )
139
126
}
140
127
}
141
128
@@ -149,21 +136,15 @@ where
149
136
///
150
137
/// Gen-kill problems should use `new_gen_kill`, which will coalesce transfer functions for
151
138
/// better performance.
152
- pub fn new_generic (
153
- tcx : TyCtxt < ' tcx > ,
154
- body : & ' a mir:: Body < ' tcx > ,
155
- analysis : A ,
156
- blocks : Blocks ,
157
- ) -> Self {
158
- Self :: new ( tcx, body, analysis, None , blocks)
139
+ pub fn new_generic ( tcx : TyCtxt < ' tcx > , body : & ' a mir:: Body < ' tcx > , analysis : A ) -> Self {
140
+ Self :: new ( tcx, body, analysis, None )
159
141
}
160
142
161
143
fn new (
162
144
tcx : TyCtxt < ' tcx > ,
163
145
body : & ' a mir:: Body < ' tcx > ,
164
146
analysis : A ,
165
147
apply_trans_for_block : Option < Box < dyn Fn ( BasicBlock , & mut A :: Domain ) > > ,
166
- blocks : Blocks ,
167
148
) -> Self {
168
149
let bottom_value = analysis. bottom_value ( body) ;
169
150
let mut entry_sets = IndexVec :: from_elem ( bottom_value. clone ( ) , & body. basic_blocks ) ;
@@ -181,7 +162,6 @@ where
181
162
pass_name : None ,
182
163
entry_sets,
183
164
apply_trans_for_block,
184
- blocks,
185
165
}
186
166
}
187
167
@@ -217,7 +197,6 @@ where
217
197
tcx,
218
198
apply_trans_for_block,
219
199
pass_name,
220
- blocks,
221
200
..
222
201
} = self ;
223
202
@@ -226,23 +205,13 @@ where
226
205
let mut visited = BitSet :: new_empty ( body. basic_blocks . len ( ) ) ;
227
206
228
207
if A :: Direction :: IS_FORWARD {
229
- match blocks {
230
- Blocks :: All => {
231
- for ( bb, _) in traversal:: reverse_postorder ( body) {
232
- dirty_queue. insert ( bb) ;
233
- }
234
- }
235
- Blocks :: Reachable => {
236
- dirty_queue. insert ( mir:: START_BLOCK ) ;
237
- }
238
- }
208
+ dirty_queue. insert ( mir:: START_BLOCK ) ;
239
209
} else {
240
210
// Reverse post-order on the reverse CFG may generate a better iteration order for
241
211
// backward dataflow analyses, but probably not enough to matter.
242
212
for ( bb, _) in traversal:: postorder ( body) {
243
213
dirty_queue. insert ( bb) ;
244
214
}
245
- assert ! ( matches!( blocks, Blocks :: All ) ) ;
246
215
}
247
216
248
217
// `state` is not actually used between iterations;
0 commit comments