diff options
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/points.rs')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/points.rs | 80 |
1 files changed, 1 insertions, 79 deletions
diff --git a/compiler/rustc_mir_dataflow/src/points.rs b/compiler/rustc_mir_dataflow/src/points.rs index 55a373d4c51..e3d1e04a319 100644 --- a/compiler/rustc_mir_dataflow/src/points.rs +++ b/compiler/rustc_mir_dataflow/src/points.rs @@ -1,9 +1,5 @@ -use rustc_index::bit_set::DenseBitSet; -use rustc_index::interval::SparseIntervalMatrix; use rustc_index::{Idx, IndexVec}; -use rustc_middle::mir::{self, BasicBlock, Body, Location}; - -use crate::framework::{Analysis, Direction, Results, ResultsVisitor, visit_results}; +use rustc_middle::mir::{BasicBlock, Body, Location}; /// Maps between a `Location` and a `PointIndex` (and vice versa). pub struct DenseLocationMap { @@ -93,77 +89,3 @@ rustc_index::newtype_index! { #[debug_format = "PointIndex({})"] pub struct PointIndex {} } - -/// Add points depending on the result of the given dataflow analysis. -pub fn save_as_intervals<'tcx, N, A>( - elements: &DenseLocationMap, - body: &mir::Body<'tcx>, - mut analysis: A, - results: Results<A::Domain>, -) -> SparseIntervalMatrix<N, PointIndex> -where - N: Idx, - A: Analysis<'tcx, Domain = DenseBitSet<N>>, -{ - let mut values = SparseIntervalMatrix::new(elements.num_points()); - let reachable_blocks = mir::traversal::reachable_as_bitset(body); - if A::Direction::IS_BACKWARD { - // Iterate blocks in decreasing order, to visit locations in decreasing order. This - // allows to use the more efficient `prepend` method to interval sets. - let callback = |state: &DenseBitSet<N>, location| { - let point = elements.point_from_location(location); - // Use internal iterator manually as it is much more efficient. - state.iter().for_each(|node| values.prepend(node, point)); - }; - let mut visitor = Visitor { callback }; - visit_results( - body, - // Note the `.rev()`. - body.basic_blocks.indices().filter(|&bb| reachable_blocks.contains(bb)).rev(), - &mut analysis, - &results, - &mut visitor, - ); - } else { - // Iterate blocks in increasing order, to visit locations in increasing order. This - // allows to use the more efficient `append` method to interval sets. - let callback = |state: &DenseBitSet<N>, location| { - let point = elements.point_from_location(location); - // Use internal iterator manually as it is much more efficient. - state.iter().for_each(|node| values.append(node, point)); - }; - let mut visitor = Visitor { callback }; - visit_results(body, reachable_blocks.iter(), &mut analysis, &results, &mut visitor); - } - values -} - -struct Visitor<F> { - callback: F, -} - -impl<'tcx, A, F> ResultsVisitor<'tcx, A> for Visitor<F> -where - A: Analysis<'tcx>, - F: FnMut(&A::Domain, Location), -{ - fn visit_after_primary_statement_effect<'mir>( - &mut self, - _analysis: &mut A, - state: &A::Domain, - _statement: &'mir mir::Statement<'tcx>, - location: Location, - ) { - (self.callback)(state, location); - } - - fn visit_after_primary_terminator_effect<'mir>( - &mut self, - _analysis: &mut A, - state: &A::Domain, - _terminator: &'mir mir::Terminator<'tcx>, - location: Location, - ) { - (self.callback)(state, location); - } -} |
