rename BitSet
to DenseBitSet
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
This commit is contained in:
parent
7e4077d06f
commit
a13354bea0
67 changed files with 367 additions and 356 deletions
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||
use std::ops::Index;
|
||||
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::bit_set::DenseBitSet;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Body, Local, Location, traversal};
|
||||
use rustc_middle::span_bug;
|
||||
|
@ -131,7 +131,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> {
|
|||
|
||||
pub enum LocalsStateAtExit {
|
||||
AllAreInvalidated,
|
||||
SomeAreInvalidated { has_storage_dead_or_moved: BitSet<Local> },
|
||||
SomeAreInvalidated { has_storage_dead_or_moved: DenseBitSet<Local> },
|
||||
}
|
||||
|
||||
impl LocalsStateAtExit {
|
||||
|
@ -140,7 +140,7 @@ impl LocalsStateAtExit {
|
|||
body: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
) -> Self {
|
||||
struct HasStorageDead(BitSet<Local>);
|
||||
struct HasStorageDead(DenseBitSet<Local>);
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for HasStorageDead {
|
||||
fn visit_local(&mut self, local: Local, ctx: PlaceContext, _: Location) {
|
||||
|
@ -153,7 +153,8 @@ impl LocalsStateAtExit {
|
|||
if locals_are_invalidated_at_exit {
|
||||
LocalsStateAtExit::AllAreInvalidated
|
||||
} else {
|
||||
let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body.local_decls.len()));
|
||||
let mut has_storage_dead =
|
||||
HasStorageDead(DenseBitSet::new_empty(body.local_decls.len()));
|
||||
has_storage_dead.visit_body(body);
|
||||
let mut has_storage_dead_or_moved = has_storage_dead.0;
|
||||
for move_out in &move_data.moves {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::graph;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::bit_set::DenseBitSet;
|
||||
use rustc_middle::mir::{
|
||||
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
|
||||
};
|
||||
|
@ -180,7 +180,7 @@ pub struct Borrows<'a, 'tcx> {
|
|||
}
|
||||
|
||||
struct OutOfScopePrecomputer<'a, 'tcx> {
|
||||
visited: BitSet<mir::BasicBlock>,
|
||||
visited: DenseBitSet<mir::BasicBlock>,
|
||||
visit_stack: Vec<mir::BasicBlock>,
|
||||
body: &'a Body<'tcx>,
|
||||
regioncx: &'a RegionInferenceContext<'tcx>,
|
||||
|
@ -190,7 +190,7 @@ struct OutOfScopePrecomputer<'a, 'tcx> {
|
|||
impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> {
|
||||
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
|
||||
OutOfScopePrecomputer {
|
||||
visited: BitSet::new_empty(body.basic_blocks.len()),
|
||||
visited: DenseBitSet::new_empty(body.basic_blocks.len()),
|
||||
visit_stack: vec![],
|
||||
body,
|
||||
regioncx,
|
||||
|
@ -292,7 +292,7 @@ pub fn calculate_borrows_out_of_scope_at_location<'tcx>(
|
|||
}
|
||||
|
||||
struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
|
||||
visited: BitSet<mir::BasicBlock>,
|
||||
visited: DenseBitSet<mir::BasicBlock>,
|
||||
visit_stack: Vec<mir::BasicBlock>,
|
||||
body: &'a Body<'tcx>,
|
||||
regioncx: &'a RegionInferenceContext<'tcx>,
|
||||
|
@ -303,7 +303,7 @@ struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
|
|||
impl<'a, 'tcx> PoloniusOutOfScopePrecomputer<'a, 'tcx> {
|
||||
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
|
||||
Self {
|
||||
visited: BitSet::new_empty(body.basic_blocks.len()),
|
||||
visited: DenseBitSet::new_empty(body.basic_blocks.len()),
|
||||
visit_stack: vec![],
|
||||
body,
|
||||
regioncx,
|
||||
|
@ -559,7 +559,7 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
type BorrowsDomain = BitSet<BorrowIndex>;
|
||||
type BorrowsDomain = DenseBitSet<BorrowIndex>;
|
||||
|
||||
/// Forward dataflow computation of the set of borrows that are in scope at a particular location.
|
||||
/// - we gen the introduced loans
|
||||
|
@ -575,7 +575,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
|
|||
|
||||
fn bottom_value(&self, _: &mir::Body<'tcx>) -> Self::Domain {
|
||||
// bottom = nothing is reserved or activated yet;
|
||||
BitSet::new_empty(self.borrow_set.len())
|
||||
DenseBitSet::new_empty(self.borrow_set.len())
|
||||
}
|
||||
|
||||
fn initialize_start_block(&self, _: &mir::Body<'tcx>, _: &mut Self::Domain) {
|
||||
|
|
|
@ -28,7 +28,7 @@ use rustc_errors::LintDiagnostic;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::CRATE_HIR_ID;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_index::bit_set::{BitSet, MixedBitSet};
|
||||
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
|
||||
use rustc_index::{IndexSlice, IndexVec};
|
||||
use rustc_infer::infer::{
|
||||
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
|
||||
|
@ -1017,11 +1017,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
|
|||
&self,
|
||||
location: Location,
|
||||
state: &'s BorrowckDomain,
|
||||
) -> Cow<'s, BitSet<BorrowIndex>> {
|
||||
) -> Cow<'s, DenseBitSet<BorrowIndex>> {
|
||||
if let Some(polonius) = &self.polonius_output {
|
||||
// Use polonius output if it has been enabled.
|
||||
let location = self.location_table.start_index(location);
|
||||
let mut polonius_output = BitSet::new_empty(self.borrow_set.len());
|
||||
let mut polonius_output = DenseBitSet::new_empty(self.borrow_set.len());
|
||||
for &idx in polonius.errors_at(location) {
|
||||
polonius_output.insert(idx);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::bit_set::DenseBitSet;
|
||||
use rustc_index::interval::IntervalSet;
|
||||
use rustc_infer::infer::canonical::QueryRegionConstraints;
|
||||
use rustc_infer::infer::outlives::for_liveness;
|
||||
|
@ -129,7 +129,7 @@ struct LivenessResults<'a, 'typeck, 'b, 'tcx> {
|
|||
cx: LivenessContext<'a, 'typeck, 'b, 'tcx>,
|
||||
|
||||
/// Set of points that define the current local.
|
||||
defs: BitSet<PointIndex>,
|
||||
defs: DenseBitSet<PointIndex>,
|
||||
|
||||
/// Points where the current variable is "use live" -- meaning
|
||||
/// that there is a future "full use" that may use its value.
|
||||
|
@ -152,7 +152,7 @@ impl<'a, 'typeck, 'b, 'tcx> LivenessResults<'a, 'typeck, 'b, 'tcx> {
|
|||
let num_points = cx.location_map.num_points();
|
||||
LivenessResults {
|
||||
cx,
|
||||
defs: BitSet::new_empty(num_points),
|
||||
defs: DenseBitSet::new_empty(num_points),
|
||||
use_live_at: IntervalSet::new(num_points),
|
||||
drop_live_at: IntervalSet::new(num_points),
|
||||
drop_locations: vec![],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue