1
Fork 0

Auto merge of #88272 - willcrichton:mutable-sparse-matrix, r=ecstatic-morse

Add bit removal methods to SparseBitMatrix and factor *BitSet relational methods into more extensible trait

I need the ability to clear the bits out of a row from `SparseBitMatrix`. Currently, all the mutating methods only allow insertion of bits, and there is no way to get access to the underlying data.

One approach is simply to make `ensure_row` public, since it grants `&mut` access to the underlying `HybridBitSet`. This PR adds the `pub` modifier. However, presumably this method was private for a reason, so I'm open to other designs. I would prefer general mutable access to the rows, because that way I can add many mutating operations (`clear`, `intersect`, etc.) without filing a PR each time :-)

r? `@ecstatic-morse`
This commit is contained in:
bors 2021-09-01 06:13:15 +00:00
commit 608b5e1c20
4 changed files with 389 additions and 132 deletions

View file

@ -160,7 +160,7 @@ impl<N: Idx> LivenessValues<N> {
/// region. Returns whether any of them are newly added.
crate fn add_elements(&mut self, row: N, locations: &HybridBitSet<PointIndex>) -> bool {
debug!("LivenessValues::add_elements(row={:?}, locations={:?})", row, locations);
self.points.union_into_row(row, locations)
self.points.union_row(row, locations)
}
/// Adds all the control-flow points to the values for `r`.
@ -294,7 +294,7 @@ impl<N: Idx> RegionValues<N> {
/// the region `to` in `self`.
crate fn merge_liveness<M: Idx>(&mut self, to: N, from: M, values: &LivenessValues<M>) {
if let Some(set) = values.points.row(from) {
self.points.union_into_row(to, set);
self.points.union_row(to, set);
}
}

View file

@ -626,7 +626,7 @@ fn compute_storage_conflicts(
// Locals that are always live or ones that need to be stored across
// suspension points are not eligible for overlap.
let mut ineligible_locals = always_live_locals.into_inner();
ineligible_locals.intersect(saved_locals);
ineligible_locals.intersect(&**saved_locals);
// Compute the storage conflicts for all eligible locals.
let mut visitor = StorageConflictVisitor {
@ -701,7 +701,7 @@ impl<'body, 'tcx, 's> StorageConflictVisitor<'body, 'tcx, 's> {
}
let mut eligible_storage_live = flow_state.clone();
eligible_storage_live.intersect(&self.saved_locals);
eligible_storage_live.intersect(&**self.saved_locals);
for local in eligible_storage_live.iter() {
self.local_conflicts.union_row_with(&eligible_storage_live, local);