Skip to content

Commit

Permalink
Fix comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Oct 21, 2023
1 parent d3f39d7 commit e57957e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions compiler/rustc_mir_dataflow/src/points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ impl DenseLocationMap {
v
})
.collect();
debug!("DenseLocationMap: statements_before_block={:#?}", statements_before_block);
debug!("DenseLocationMap: num_points={:#?}", num_points);

let mut basic_blocks = IndexVec::with_capacity(num_points);
for (bb, bb_data) in body.basic_blocks.iter_enumerated() {
Expand All @@ -57,7 +55,7 @@ impl DenseLocationMap {
PointIndex::new(start_index + statement_index)
}

/// Converts a `Location` into a `PointIndex`. O(1).
/// Returns the `PointIndex` for the first statement in the giben `BasicBlock`. O(1).
#[inline]
pub fn entry_point(&self, block: BasicBlock) -> PointIndex {
let start_index = self.statements_before_block[block];
Expand Down Expand Up @@ -106,8 +104,7 @@ pub struct LivenessValues<N: Idx> {

impl<N: Idx> LivenessValues<N> {
/// Creates a new set of "region values" that tracks causal information.
/// Each of the regions in num_region_variables will be initialized with an
/// empty set of points and no causal information.
/// Each of the regions is initialized with an empty set of points.
pub fn new(elements: Rc<DenseLocationMap>) -> Self {
Self { points: SparseIntervalMatrix::new(elements.num_points), elements }
}
Expand All @@ -126,30 +123,28 @@ impl<N: Idx> LivenessValues<N> {
/// Adds the given element to the value for the given region. Returns whether
/// the element is newly added (i.e., was not already present).
pub fn add_element(&mut self, row: N, location: Location) -> bool {
debug!("LivenessValues::add(r={:?}, location={:?})", row, location);
let index = self.elements.point_from_location(location);
self.points.insert(row, index)
}

/// Adds all the elements in the given bit array into the given
/// region. Returns whether any of them are newly added.
pub fn add_elements(&mut self, row: N, locations: &IntervalSet<PointIndex>) -> bool {
debug!("LivenessValues::add_elements(row={:?}, locations={:?})", row, locations);
self.points.union_row(row, locations)
}

/// Adds all the control-flow points to the values for `r`.
/// Adds all the control-flow points to the values for `row`.
pub fn add_all_points(&mut self, row: N) {
self.points.insert_all_into_row(row);
}

/// Returns `true` if the region `r` contains the given element.
/// Returns `true` if the region `row` contains the given element.
pub fn contains(&self, row: N, location: Location) -> bool {
let index = self.elements.point_from_location(location);
self.points.row(row).is_some_and(|r| r.contains(index))
}

/// Returns an iterator of all the elements contained by the region `r`
/// Returns an iterator of all the elements contained by the region `row`
pub fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_ {
self.points
.row(row)
Expand Down

0 comments on commit e57957e

Please sign in to comment.