7171 }
7272}
7373
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-
8174/// A solver for dataflow problems.
8275pub struct Engine < ' a , ' tcx , A >
8376where
9790 // performance in practice. I've tried a few ways to avoid this, but they have downsides. See
9891 // the message for the commit that added this FIXME for more information.
9992 apply_trans_for_block : Option < Box < dyn Fn ( BasicBlock , & mut A :: Domain ) > > ,
100- blocks : Blocks ,
10193}
10294
10395impl < ' a , ' tcx , A , D , T > Engine < ' a , ' tcx , A >
@@ -107,18 +99,13 @@ where
10799 T : Idx ,
108100{
109101 /// 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 {
116103 // If there are no back-edges in the control-flow graph, we only ever need to apply the
117104 // transfer function for each block exactly once (assuming that we process blocks in RPO).
118105 //
119106 // In this case, there's no need to compute the block transfer functions ahead of time.
120107 if !body. basic_blocks . is_cfg_cyclic ( ) {
121- return Self :: new ( tcx, body, analysis, None , blocks ) ;
108+ return Self :: new ( tcx, body, analysis, None ) ;
122109 }
123110
124111 // Otherwise, compute and store the cumulative transfer function for each block.
@@ -135,7 +122,7 @@ where
135122 trans_for_block[ bb] . apply ( state) ;
136123 } ) ;
137124
138- Self :: new ( tcx, body, analysis, Some ( apply_trans as Box < _ > ) , blocks )
125+ Self :: new ( tcx, body, analysis, Some ( apply_trans as Box < _ > ) )
139126 }
140127}
141128
@@ -149,21 +136,15 @@ where
149136 ///
150137 /// Gen-kill problems should use `new_gen_kill`, which will coalesce transfer functions for
151138 /// 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 )
159141 }
160142
161143 fn new (
162144 tcx : TyCtxt < ' tcx > ,
163145 body : & ' a mir:: Body < ' tcx > ,
164146 analysis : A ,
165147 apply_trans_for_block : Option < Box < dyn Fn ( BasicBlock , & mut A :: Domain ) > > ,
166- blocks : Blocks ,
167148 ) -> Self {
168149 let bottom_value = analysis. bottom_value ( body) ;
169150 let mut entry_sets = IndexVec :: from_elem ( bottom_value. clone ( ) , & body. basic_blocks ) ;
@@ -181,7 +162,6 @@ where
181162 pass_name : None ,
182163 entry_sets,
183164 apply_trans_for_block,
184- blocks,
185165 }
186166 }
187167
@@ -217,7 +197,6 @@ where
217197 tcx,
218198 apply_trans_for_block,
219199 pass_name,
220- blocks,
221200 ..
222201 } = self ;
223202
@@ -226,23 +205,13 @@ where
226205 let mut visited = BitSet :: new_empty ( body. basic_blocks . len ( ) ) ;
227206
228207 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 ) ;
239209 } else {
240210 // Reverse post-order on the reverse CFG may generate a better iteration order for
241211 // backward dataflow analyses, but probably not enough to matter.
242212 for ( bb, _) in traversal:: postorder ( body) {
243213 dirty_queue. insert ( bb) ;
244214 }
245- assert ! ( matches!( blocks, Blocks :: All ) ) ;
246215 }
247216
248217 // `state` is not actually used between iterations;
0 commit comments