Rename FlowState
as Domain
.
Because that's what it is; no point having a different name for it.
This commit is contained in:
parent
55c9f96265
commit
bb943f93ff
10 changed files with 160 additions and 163 deletions
|
@ -42,14 +42,14 @@ pub trait Direction {
|
|||
) where
|
||||
A: GenKillAnalysis<'tcx>;
|
||||
|
||||
fn visit_results_in_block<'mir, 'tcx, F, R>(
|
||||
state: &mut F,
|
||||
fn visit_results_in_block<'mir, 'tcx, D, R>(
|
||||
state: &mut D,
|
||||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
results: &mut R,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, FlowState = F>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
|
||||
) where
|
||||
R: ResultsVisitable<'tcx, FlowState = F>;
|
||||
R: ResultsVisitable<'tcx, Domain = D>;
|
||||
|
||||
fn join_state_into_successors_of<'tcx, A>(
|
||||
analysis: &mut A,
|
||||
|
@ -186,14 +186,14 @@ impl Direction for Backward {
|
|||
analysis.apply_statement_effect(state, statement, location);
|
||||
}
|
||||
|
||||
fn visit_results_in_block<'mir, 'tcx, F, R>(
|
||||
state: &mut F,
|
||||
fn visit_results_in_block<'mir, 'tcx, D, R>(
|
||||
state: &mut D,
|
||||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
results: &mut R,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, FlowState = F>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
|
||||
) where
|
||||
R: ResultsVisitable<'tcx, FlowState = F>,
|
||||
R: ResultsVisitable<'tcx, Domain = D>,
|
||||
{
|
||||
results.reset_to_block_entry(state, block);
|
||||
|
||||
|
@ -444,9 +444,9 @@ impl Direction for Forward {
|
|||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
results: &mut R,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, FlowState = F>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = F>,
|
||||
) where
|
||||
R: ResultsVisitable<'tcx, FlowState = F>,
|
||||
R: ResultsVisitable<'tcx, Domain = F>,
|
||||
{
|
||||
results.reset_to_block_entry(state, block);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ where
|
|||
&mut self,
|
||||
body: &'mir mir::Body<'tcx>,
|
||||
blocks: impl IntoIterator<Item = BasicBlock>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, FlowState = A::Domain>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
|
||||
) {
|
||||
visit_results(body, blocks, self, vis)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ where
|
|||
pub fn visit_reachable_with<'mir>(
|
||||
&mut self,
|
||||
body: &'mir mir::Body<'tcx>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, FlowState = A::Domain>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, Self, Domain = A::Domain>,
|
||||
) {
|
||||
let blocks = mir::traversal::reachable(body);
|
||||
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
|
||||
|
|
|
@ -544,15 +544,15 @@ where
|
|||
A: Analysis<'tcx>,
|
||||
A::Domain: DebugWithContext<A>,
|
||||
{
|
||||
type FlowState = A::Domain;
|
||||
type Domain = A::Domain;
|
||||
|
||||
fn visit_block_start(&mut self, state: &Self::FlowState) {
|
||||
fn visit_block_start(&mut self, state: &Self::Domain) {
|
||||
if A::Direction::IS_FORWARD {
|
||||
self.prev_state.clone_from(state);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_block_end(&mut self, state: &Self::FlowState) {
|
||||
fn visit_block_end(&mut self, state: &Self::Domain) {
|
||||
if A::Direction::IS_BACKWARD {
|
||||
self.prev_state.clone_from(state);
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ where
|
|||
fn visit_statement_before_primary_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -574,7 +574,7 @@ where
|
|||
fn visit_statement_after_primary_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_statement: &mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -585,7 +585,7 @@ where
|
|||
fn visit_terminator_before_primary_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -598,7 +598,7 @@ where
|
|||
fn visit_terminator_after_primary_effect(
|
||||
&mut self,
|
||||
results: &mut Results<'tcx, A>,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_terminator: &mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
|
|
@ -4,15 +4,15 @@ use super::{Analysis, Direction, Results};
|
|||
|
||||
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
|
||||
/// dataflow state at that location.
|
||||
pub fn visit_results<'mir, 'tcx, F, R>(
|
||||
pub fn visit_results<'mir, 'tcx, D, R>(
|
||||
body: &'mir mir::Body<'tcx>,
|
||||
blocks: impl IntoIterator<Item = BasicBlock>,
|
||||
results: &mut R,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, FlowState = F>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, R, Domain = D>,
|
||||
) where
|
||||
R: ResultsVisitable<'tcx, FlowState = F>,
|
||||
R: ResultsVisitable<'tcx, Domain = D>,
|
||||
{
|
||||
let mut state = results.new_flow_state(body);
|
||||
let mut state = results.bottom_value(body);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
let reachable_blocks = mir::traversal::reachable_as_bitset(body);
|
||||
|
@ -29,16 +29,16 @@ pub fn visit_results<'mir, 'tcx, F, R>(
|
|||
/// A visitor over the results of an `Analysis`. The type parameter `R` is the results type being
|
||||
/// visited.
|
||||
pub trait ResultsVisitor<'mir, 'tcx, R> {
|
||||
type FlowState;
|
||||
type Domain;
|
||||
|
||||
fn visit_block_start(&mut self, _state: &Self::FlowState) {}
|
||||
fn visit_block_start(&mut self, _state: &Self::Domain) {}
|
||||
|
||||
/// Called with the `before_statement_effect` of the given statement applied to `state` but not
|
||||
/// its `statement_effect`.
|
||||
fn visit_statement_before_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
_state: &Self::FlowState,
|
||||
_state: &Self::Domain,
|
||||
_statement: &'mir mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -49,7 +49,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
|
|||
fn visit_statement_after_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
_state: &Self::FlowState,
|
||||
_state: &Self::Domain,
|
||||
_statement: &'mir mir::Statement<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -60,7 +60,7 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
|
|||
fn visit_terminator_before_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
_state: &Self::FlowState,
|
||||
_state: &Self::Domain,
|
||||
_terminator: &'mir mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
|
@ -73,13 +73,13 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
|
|||
fn visit_terminator_after_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
_state: &Self::FlowState,
|
||||
_state: &Self::Domain,
|
||||
_terminator: &'mir mir::Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) {
|
||||
}
|
||||
|
||||
fn visit_block_end(&mut self, _state: &Self::FlowState) {}
|
||||
fn visit_block_end(&mut self, _state: &Self::Domain) {}
|
||||
}
|
||||
|
||||
/// Things that can be visited by a `ResultsVisitor`.
|
||||
|
@ -88,40 +88,40 @@ pub trait ResultsVisitor<'mir, 'tcx, R> {
|
|||
/// simultaneously.
|
||||
pub trait ResultsVisitable<'tcx> {
|
||||
type Direction: Direction;
|
||||
type FlowState;
|
||||
type Domain;
|
||||
|
||||
/// Creates an empty `FlowState` to hold the transient state for these dataflow results.
|
||||
/// Creates an empty `Domain` to hold the transient state for these dataflow results.
|
||||
///
|
||||
/// The value of the newly created `FlowState` will be overwritten by `reset_to_block_entry`
|
||||
/// The value of the newly created `Domain` will be overwritten by `reset_to_block_entry`
|
||||
/// before it can be observed by a `ResultsVisitor`.
|
||||
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState;
|
||||
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain;
|
||||
|
||||
fn reset_to_block_entry(&self, state: &mut Self::FlowState, block: BasicBlock);
|
||||
fn reset_to_block_entry(&self, state: &mut Self::Domain, block: BasicBlock);
|
||||
|
||||
fn reconstruct_before_statement_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
statement: &mir::Statement<'tcx>,
|
||||
location: Location,
|
||||
);
|
||||
|
||||
fn reconstruct_statement_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
statement: &mir::Statement<'tcx>,
|
||||
location: Location,
|
||||
);
|
||||
|
||||
fn reconstruct_before_terminator_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
terminator: &mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
);
|
||||
|
||||
fn reconstruct_terminator_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
terminator: &mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
);
|
||||
|
@ -131,21 +131,20 @@ impl<'tcx, A> ResultsVisitable<'tcx> for Results<'tcx, A>
|
|||
where
|
||||
A: Analysis<'tcx>,
|
||||
{
|
||||
type FlowState = A::Domain;
|
||||
|
||||
type Domain = A::Domain;
|
||||
type Direction = A::Direction;
|
||||
|
||||
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
|
||||
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
|
||||
self.analysis.bottom_value(body)
|
||||
}
|
||||
|
||||
fn reset_to_block_entry(&self, state: &mut Self::FlowState, block: BasicBlock) {
|
||||
fn reset_to_block_entry(&self, state: &mut Self::Domain, block: BasicBlock) {
|
||||
state.clone_from(self.entry_set_for_block(block));
|
||||
}
|
||||
|
||||
fn reconstruct_before_statement_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
|
@ -154,7 +153,7 @@ where
|
|||
|
||||
fn reconstruct_statement_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
|
@ -163,7 +162,7 @@ where
|
|||
|
||||
fn reconstruct_before_terminator_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
|
@ -172,7 +171,7 @@ where
|
|||
|
||||
fn reconstruct_terminator_effect(
|
||||
&mut self,
|
||||
state: &mut Self::FlowState,
|
||||
state: &mut Self::Domain,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
|
|
|
@ -102,7 +102,7 @@ pub fn save_as_intervals<'tcx, N, R>(
|
|||
) -> SparseIntervalMatrix<N, PointIndex>
|
||||
where
|
||||
N: Idx,
|
||||
R: ResultsVisitable<'tcx, FlowState = BitSet<N>>,
|
||||
R: ResultsVisitable<'tcx, Domain = BitSet<N>>,
|
||||
{
|
||||
let values = SparseIntervalMatrix::new(elements.num_points());
|
||||
let mut visitor = Visitor { elements, values };
|
||||
|
@ -124,12 +124,12 @@ impl<'mir, 'tcx, R, N> ResultsVisitor<'mir, 'tcx, R> for Visitor<'_, N>
|
|||
where
|
||||
N: Idx,
|
||||
{
|
||||
type FlowState = BitSet<N>;
|
||||
type Domain = BitSet<N>;
|
||||
|
||||
fn visit_statement_after_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_statement: &'mir mir::Statement<'tcx>,
|
||||
location: Location,
|
||||
) {
|
||||
|
@ -143,7 +143,7 @@ where
|
|||
fn visit_terminator_after_primary_effect(
|
||||
&mut self,
|
||||
_results: &mut R,
|
||||
state: &Self::FlowState,
|
||||
state: &Self::Domain,
|
||||
_terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) {
|
||||
|
|
|
@ -229,7 +229,7 @@ trait RustcPeekAt<'tcx>: Analysis<'tcx> {
|
|||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
place: mir::Place<'tcx>,
|
||||
flow_state: &Self::Domain,
|
||||
state: &Self::Domain,
|
||||
call: PeekCall,
|
||||
);
|
||||
}
|
||||
|
@ -243,12 +243,12 @@ where
|
|||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
place: mir::Place<'tcx>,
|
||||
flow_state: &Self::Domain,
|
||||
state: &Self::Domain,
|
||||
call: PeekCall,
|
||||
) {
|
||||
match self.move_data().rev_lookup.find(place.as_ref()) {
|
||||
LookupResult::Exact(peek_mpi) => {
|
||||
let bit_state = flow_state.contains(peek_mpi);
|
||||
let bit_state = state.contains(peek_mpi);
|
||||
debug!("rustc_peek({:?} = &{:?}) bit_state: {}", call.arg, place, bit_state);
|
||||
if !bit_state {
|
||||
tcx.dcx().emit_err(PeekBitNotSet { span: call.span });
|
||||
|
@ -267,7 +267,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeLiveLocals {
|
|||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
place: mir::Place<'tcx>,
|
||||
flow_state: &BitSet<Local>,
|
||||
state: &BitSet<Local>,
|
||||
call: PeekCall,
|
||||
) {
|
||||
info!(?place, "peek_at");
|
||||
|
@ -276,7 +276,7 @@ impl<'tcx> RustcPeekAt<'tcx> for MaybeLiveLocals {
|
|||
return;
|
||||
};
|
||||
|
||||
if !flow_state.contains(local) {
|
||||
if !state.contains(local) {
|
||||
tcx.dcx().emit_err(PeekBitNotSet { span: call.span });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue