Skip to content

Commit 8b67c5e

Browse files
committed
iterate_to_fixpoint -> iterate_reachable_to_fixpoint
* Renames `iterate_to_fixpoint` to `iterate_reachable_to_fixpoint`. * Adds to `framework::Enginge` a new method with the old name (`iterate_to_fixpoint`). The new method computes the fixpoint over all basic blocks, instead of just the reachable ones. * Changes one occurrence of `iterate_to_fixpoint` to `iterate_reachable_to_fixpoint` where the analysis seemed to care about only reachable basic blocks.
1 parent 8769f4e commit 8b67c5e

File tree

2 files changed

+39
-15
lines changed

2 files changed

+39
-15
lines changed

compiler/rustc_mir_dataflow/src/framework/engine.rs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,37 +181,61 @@ where
181181
self
182182
}
183183

184-
/// Computes the fixpoint for this dataflow problem and returns it.
184+
/// Computes the fixpoint for this dataflow problem over all basic blocks and returns the
185+
/// fixpoint.
185186
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
186187
where
187188
A::Domain: DebugWithContext<A>,
188189
{
189-
let Engine {
190-
analysis,
191-
body,
192-
dead_unwinds,
193-
mut entry_sets,
194-
tcx,
195-
apply_trans_for_block,
196-
pass_name,
197-
..
198-
} = self;
190+
let mut dirty_queue: WorkQueue<BasicBlock> =
191+
WorkQueue::with_none(self.body.basic_blocks().len());
192+
193+
self.body.basic_blocks().indices().for_each(|bb| {
194+
dirty_queue.insert(bb);
195+
});
199196

197+
self.iterate_to_fixpoint_inner(dirty_queue)
198+
}
199+
200+
/// Computes the fixpoint for this dataflow problem over the reachable basic blocks and returns
201+
/// the fixpoint.
202+
pub fn iterate_reachable_to_fixpoint(self) -> Results<'tcx, A>
203+
where
204+
A::Domain: DebugWithContext<A>,
205+
{
200206
let mut dirty_queue: WorkQueue<BasicBlock> =
201-
WorkQueue::with_none(body.basic_blocks().len());
207+
WorkQueue::with_none(self.body.basic_blocks().len());
202208

203209
if A::Direction::is_forward() {
204-
for (bb, _) in traversal::reverse_postorder(body) {
210+
for (bb, _) in traversal::reverse_postorder(self.body) {
205211
dirty_queue.insert(bb);
206212
}
207213
} else {
208214
// Reverse post-order on the reverse CFG may generate a better iteration order for
209215
// backward dataflow analyses, but probably not enough to matter.
210-
for (bb, _) in traversal::postorder(body) {
216+
for (bb, _) in traversal::postorder(self.body) {
211217
dirty_queue.insert(bb);
212218
}
213219
}
214220

221+
self.iterate_to_fixpoint_inner(dirty_queue)
222+
}
223+
224+
fn iterate_to_fixpoint_inner(self, mut dirty_queue: WorkQueue<BasicBlock>) -> Results<'tcx, A>
225+
where
226+
A::Domain: DebugWithContext<A>,
227+
{
228+
let Engine {
229+
analysis,
230+
body,
231+
dead_unwinds,
232+
mut entry_sets,
233+
tcx,
234+
apply_trans_for_block,
235+
pass_name,
236+
..
237+
} = self;
238+
215239
// `state` is not actually used between iterations;
216240
// this is just an optimization to avoid reallocating
217241
// every iteration.

compiler/rustc_mir_transform/src/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ fn locals_live_across_suspend_points<'tcx>(
473473
// for.
474474
let requires_storage_results = MaybeRequiresStorage::new(body, &borrowed_locals_results)
475475
.into_engine(tcx, body_ref)
476-
.iterate_to_fixpoint();
476+
.iterate_reachable_to_fixpoint();
477477
let mut requires_storage_cursor =
478478
rustc_mir_dataflow::ResultsCursor::new(body_ref, &requires_storage_results);
479479

0 commit comments

Comments
 (0)