Rename EntrySets
as EntryStates
.
"Set" doesn't make much sense here, we refer to domain values as "state" everywhere else. (This name confused me for a while.)
This commit is contained in:
parent
2298104f3f
commit
b059ea857c
5 changed files with 22 additions and 21 deletions
|
@ -43,7 +43,7 @@ use rustc_mir_dataflow::impls::{
|
||||||
use rustc_mir_dataflow::move_paths::{
|
use rustc_mir_dataflow::move_paths::{
|
||||||
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
|
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
|
||||||
};
|
};
|
||||||
use rustc_mir_dataflow::{Analysis, EntrySets, Results, ResultsVisitor, visit_results};
|
use rustc_mir_dataflow::{Analysis, EntryStates, Results, ResultsVisitor, visit_results};
|
||||||
use rustc_session::lint::builtin::UNUSED_MUT;
|
use rustc_session::lint::builtin::UNUSED_MUT;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -426,14 +426,14 @@ fn get_flow_results<'a, 'tcx>(
|
||||||
ever_inits: ever_inits.analysis,
|
ever_inits: ever_inits.analysis,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(borrows.entry_sets.len(), uninits.entry_sets.len());
|
assert_eq!(borrows.entry_states.len(), uninits.entry_states.len());
|
||||||
assert_eq!(borrows.entry_sets.len(), ever_inits.entry_sets.len());
|
assert_eq!(borrows.entry_states.len(), ever_inits.entry_states.len());
|
||||||
let entry_sets: EntrySets<'_, Borrowck<'_, '_>> =
|
let entry_states: EntryStates<'_, Borrowck<'_, '_>> =
|
||||||
itertools::izip!(borrows.entry_sets, uninits.entry_sets, ever_inits.entry_sets)
|
itertools::izip!(borrows.entry_states, uninits.entry_states, ever_inits.entry_states)
|
||||||
.map(|(borrows, uninits, ever_inits)| BorrowckDomain { borrows, uninits, ever_inits })
|
.map(|(borrows, uninits, ever_inits)| BorrowckDomain { borrows, uninits, ever_inits })
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Results { analysis, entry_sets }
|
Results { analysis, entry_states }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct BorrowckInferCtxt<'tcx> {
|
pub(crate) struct BorrowckInferCtxt<'tcx> {
|
||||||
|
|
|
@ -56,7 +56,7 @@ mod visitor;
|
||||||
pub use self::cursor::ResultsCursor;
|
pub use self::cursor::ResultsCursor;
|
||||||
pub use self::direction::{Backward, Direction, Forward};
|
pub use self::direction::{Backward, Direction, Forward};
|
||||||
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
|
pub use self::lattice::{JoinSemiLattice, MaybeReachable};
|
||||||
pub use self::results::{EntrySets, Results};
|
pub use self::results::{EntryStates, Results};
|
||||||
pub use self::visitor::{ResultsVisitor, visit_results};
|
pub use self::visitor::{ResultsVisitor, visit_results};
|
||||||
|
|
||||||
/// Analysis domains are all bitsets of various kinds. This trait holds
|
/// Analysis domains are all bitsets of various kinds. This trait holds
|
||||||
|
@ -234,11 +234,12 @@ pub trait Analysis<'tcx> {
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
Self::Domain: DebugWithContext<Self>,
|
Self::Domain: DebugWithContext<Self>,
|
||||||
{
|
{
|
||||||
let mut entry_sets =
|
let mut entry_states =
|
||||||
IndexVec::from_fn_n(|_| self.bottom_value(body), body.basic_blocks.len());
|
IndexVec::from_fn_n(|_| self.bottom_value(body), body.basic_blocks.len());
|
||||||
self.initialize_start_block(body, &mut entry_sets[mir::START_BLOCK]);
|
self.initialize_start_block(body, &mut entry_states[mir::START_BLOCK]);
|
||||||
|
|
||||||
if Self::Direction::IS_BACKWARD && entry_sets[mir::START_BLOCK] != self.bottom_value(body) {
|
if Self::Direction::IS_BACKWARD && entry_states[mir::START_BLOCK] != self.bottom_value(body)
|
||||||
|
{
|
||||||
bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
|
bug!("`initialize_start_block` is not yet supported for backward dataflow analyses");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +263,9 @@ pub trait Analysis<'tcx> {
|
||||||
let mut state = self.bottom_value(body);
|
let mut state = self.bottom_value(body);
|
||||||
while let Some(bb) = dirty_queue.pop() {
|
while let Some(bb) = dirty_queue.pop() {
|
||||||
// Set the state to the entry state of the block.
|
// Set the state to the entry state of the block.
|
||||||
// This is equivalent to `state = entry_sets[bb].clone()`,
|
// This is equivalent to `state = entry_states[bb].clone()`,
|
||||||
// but it saves an allocation, thus improving compile times.
|
// but it saves an allocation, thus improving compile times.
|
||||||
state.clone_from(&entry_sets[bb]);
|
state.clone_from(&entry_states[bb]);
|
||||||
|
|
||||||
Self::Direction::apply_effects_in_block(
|
Self::Direction::apply_effects_in_block(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -273,7 +274,7 @@ pub trait Analysis<'tcx> {
|
||||||
bb,
|
bb,
|
||||||
&body[bb],
|
&body[bb],
|
||||||
|target: BasicBlock, state: &Self::Domain| {
|
|target: BasicBlock, state: &Self::Domain| {
|
||||||
let set_changed = entry_sets[target].join(state);
|
let set_changed = entry_states[target].join(state);
|
||||||
if set_changed {
|
if set_changed {
|
||||||
dirty_queue.insert(target);
|
dirty_queue.insert(target);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ pub trait Analysis<'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut results = Results { analysis: self, entry_sets };
|
let mut results = Results { analysis: self, entry_states };
|
||||||
|
|
||||||
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
|
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
|
||||||
let res = write_graphviz_results(tcx, body, &mut results, pass_name);
|
let res = write_graphviz_results(tcx, body, &mut results, pass_name);
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::errors::{
|
||||||
};
|
};
|
||||||
use crate::framework::cursor::ResultsHandle;
|
use crate::framework::cursor::ResultsHandle;
|
||||||
|
|
||||||
pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as Analysis<'tcx>>::Domain>;
|
pub type EntryStates<'tcx, A> = IndexVec<BasicBlock, <A as Analysis<'tcx>>::Domain>;
|
||||||
|
|
||||||
/// A dataflow analysis that has converged to fixpoint. It only holds the domain values at the
|
/// A dataflow analysis that has converged to fixpoint. It only holds the domain values at the
|
||||||
/// entry of each basic block. Domain values in other parts of the block are recomputed on the fly
|
/// entry of each basic block. Domain values in other parts of the block are recomputed on the fly
|
||||||
|
@ -30,7 +30,7 @@ where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
pub analysis: A,
|
pub analysis: A,
|
||||||
pub entry_sets: EntrySets<'tcx, A>,
|
pub entry_states: EntryStates<'tcx, A>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, A> Results<'tcx, A>
|
impl<'tcx, A> Results<'tcx, A>
|
||||||
|
@ -56,7 +56,7 @@ where
|
||||||
|
|
||||||
/// Gets the dataflow state for the given block.
|
/// Gets the dataflow state for the given block.
|
||||||
pub fn entry_set_for_block(&self, block: BasicBlock) -> &A::Domain {
|
pub fn entry_set_for_block(&self, block: BasicBlock) -> &A::Domain {
|
||||||
&self.entry_sets[block]
|
&self.entry_states[block]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn visit_with<'mir>(
|
pub fn visit_with<'mir>(
|
||||||
|
|
|
@ -73,7 +73,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> {
|
||||||
///
|
///
|
||||||
/// The `102` in the block's entry set is derived from the basic block index and ensures that the
|
/// The `102` in the block's entry set is derived from the basic block index and ensures that the
|
||||||
/// expected state is unique across all basic blocks. Remember, it is generated by
|
/// expected state is unique across all basic blocks. Remember, it is generated by
|
||||||
/// `mock_entry_sets`, not from actually running `MockAnalysis` to fixpoint.
|
/// `mock_entry_states`, not from actually running `MockAnalysis` to fixpoint.
|
||||||
struct MockAnalysis<'tcx, D> {
|
struct MockAnalysis<'tcx, D> {
|
||||||
body: &'tcx mir::Body<'tcx>,
|
body: &'tcx mir::Body<'tcx>,
|
||||||
dir: PhantomData<D>,
|
dir: PhantomData<D>,
|
||||||
|
@ -90,7 +90,7 @@ impl<D: Direction> MockAnalysis<'_, D> {
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mock_entry_sets(&self) -> IndexVec<BasicBlock, BitSet<usize>> {
|
fn mock_entry_states(&self) -> IndexVec<BasicBlock, BitSet<usize>> {
|
||||||
let empty = self.bottom_value(self.body);
|
let empty = self.bottom_value(self.body);
|
||||||
let mut ret = IndexVec::from_elem(empty, &self.body.basic_blocks);
|
let mut ret = IndexVec::from_elem(empty, &self.body.basic_blocks);
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
|
||||||
let body = analysis.body;
|
let body = analysis.body;
|
||||||
|
|
||||||
let mut cursor =
|
let mut cursor =
|
||||||
Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_results_cursor(body);
|
Results { entry_states: analysis.mock_entry_states(), analysis }.into_results_cursor(body);
|
||||||
|
|
||||||
cursor.allow_unreachable();
|
cursor.allow_unreachable();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub use self::drop_flag_effects::{
|
||||||
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
|
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
|
||||||
};
|
};
|
||||||
pub use self::framework::{
|
pub use self::framework::{
|
||||||
Analysis, Backward, Direction, EntrySets, Forward, GenKill, JoinSemiLattice, MaybeReachable,
|
Analysis, Backward, Direction, EntryStates, Forward, GenKill, JoinSemiLattice, MaybeReachable,
|
||||||
Results, ResultsCursor, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz, lattice,
|
Results, ResultsCursor, ResultsVisitor, SwitchIntEdgeEffects, fmt, graphviz, lattice,
|
||||||
visit_results,
|
visit_results,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue