]> git.lizzy.rs Git - rust.git/commitdiff
Add inherent `visit_with` method to `dataflow::Results`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Tue, 18 Feb 2020 17:51:21 +0000 (09:51 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 27 Feb 2020 18:53:00 +0000 (10:53 -0800)
This is more ergonomic than importing `dataflow::visit_results`

src/librustc_mir/dataflow/generic/mod.rs

index c61b7bed3538b5b49c6c73aae912cfb578100f90..26aa933f423706972e0e3d3ce23a3e37f531e8d8 100644 (file)
@@ -75,6 +75,24 @@ pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'
     pub fn entry_set_for_block(&self, block: BasicBlock) -> &BitSet<A::Idx> {
         &self.entry_sets[block]
     }
+
+    pub fn visit_with(
+        &self,
+        body: &'mir mir::Body<'tcx>,
+        blocks: impl IntoIterator<Item = BasicBlock>,
+        vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
+    ) {
+        visit_results(body, blocks, self, vis)
+    }
+
+    pub fn visit_in_rpo_with(
+        &self,
+        body: &'mir mir::Body<'tcx>,
+        vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = BitSet<A::Idx>>,
+    ) {
+        let blocks = mir::traversal::reverse_postorder(body);
+        visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
+    }
 }
 
 /// Define the domain of a dataflow problem.