Skip to content

Commit 6d7ce88

Browse files
Add inherent visit_with method to dataflow::Results
This is more ergonomic than importing `dataflow::visit_results`
1 parent 5fa2c9e commit 6d7ce88

File tree

1 file changed

+18
-0
lines changed
  • src/librustc_mir/dataflow/generic

1 file changed

+18
-0
lines changed

src/librustc_mir/dataflow/generic/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ where
7575
pub fn entry_set_for_block(&self, block: BasicBlock) -> &BitSet<A::Idx> {
7676
&self.entry_sets[block]
7777
}
78+
79+
pub fn visit_with(
80+
&self,
81+
body: &'mir mir::Body<'tcx>,
82+
blocks: impl IntoIterator<Item = BasicBlock>,
83+
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
84+
) {
85+
visit_results(body, blocks, self, vis)
86+
}
87+
88+
pub fn visit_in_rpo_with(
89+
&self,
90+
body: &'mir mir::Body<'tcx>,
91+
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
92+
) {
93+
let blocks = mir::traversal::reverse_postorder(body);
94+
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
95+
}
7896
}
7997

8098
/// Define the domain of a dataflow problem.

0 commit comments

Comments
 (0)