Make TerminatorEdge plural.
This commit is contained in:
parent
6cf15d4cb5
commit
388f6a6413
12 changed files with 59 additions and 59 deletions
|
@ -1,5 +1,5 @@
|
|||
use rustc_middle::mir::{
|
||||
self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdge, UnwindAction,
|
||||
self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdges, UnwindAction,
|
||||
};
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub trait Direction {
|
|||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
statement_effect: Option<&dyn Fn(BasicBlock, &mut A::Domain)>,
|
||||
) -> TerminatorEdge<'mir, 'tcx>
|
||||
) -> TerminatorEdges<'mir, 'tcx>
|
||||
where
|
||||
A: Analysis<'tcx>;
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub trait Direction {
|
|||
body: &mir::Body<'tcx>,
|
||||
exit_state: &mut A::Domain,
|
||||
block: BasicBlock,
|
||||
edges: TerminatorEdge<'_, 'tcx>,
|
||||
edges: TerminatorEdges<'_, 'tcx>,
|
||||
propagate: impl FnMut(BasicBlock, &A::Domain),
|
||||
) where
|
||||
A: Analysis<'tcx>;
|
||||
|
@ -73,7 +73,7 @@ impl Direction for Backward {
|
|||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
statement_effect: Option<&dyn Fn(BasicBlock, &mut A::Domain)>,
|
||||
) -> TerminatorEdge<'mir, 'tcx>
|
||||
) -> TerminatorEdges<'mir, 'tcx>
|
||||
where
|
||||
A: Analysis<'tcx>,
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ impl Direction for Backward {
|
|||
body: &mir::Body<'tcx>,
|
||||
exit_state: &mut A::Domain,
|
||||
bb: BasicBlock,
|
||||
_edges: TerminatorEdge<'_, 'tcx>,
|
||||
_edges: TerminatorEdges<'_, 'tcx>,
|
||||
mut propagate: impl FnMut(BasicBlock, &A::Domain),
|
||||
) where
|
||||
A: Analysis<'tcx>,
|
||||
|
@ -330,7 +330,7 @@ impl Direction for Forward {
|
|||
block: BasicBlock,
|
||||
block_data: &'mir mir::BasicBlockData<'tcx>,
|
||||
statement_effect: Option<&dyn Fn(BasicBlock, &mut A::Domain)>,
|
||||
) -> TerminatorEdge<'mir, 'tcx>
|
||||
) -> TerminatorEdges<'mir, 'tcx>
|
||||
where
|
||||
A: Analysis<'tcx>,
|
||||
{
|
||||
|
@ -474,19 +474,19 @@ impl Direction for Forward {
|
|||
_body: &mir::Body<'tcx>,
|
||||
exit_state: &mut A::Domain,
|
||||
bb: BasicBlock,
|
||||
edges: TerminatorEdge<'_, 'tcx>,
|
||||
edges: TerminatorEdges<'_, 'tcx>,
|
||||
mut propagate: impl FnMut(BasicBlock, &A::Domain),
|
||||
) where
|
||||
A: Analysis<'tcx>,
|
||||
{
|
||||
match edges {
|
||||
TerminatorEdge::None => {}
|
||||
TerminatorEdge::Single(target) => propagate(target, exit_state),
|
||||
TerminatorEdge::Double(target, unwind) => {
|
||||
TerminatorEdges::None => {}
|
||||
TerminatorEdges::Single(target) => propagate(target, exit_state),
|
||||
TerminatorEdges::Double(target, unwind) => {
|
||||
propagate(target, exit_state);
|
||||
propagate(unwind, exit_state);
|
||||
}
|
||||
TerminatorEdge::AssignOnReturn { return_, unwind, place } => {
|
||||
TerminatorEdges::AssignOnReturn { return_, unwind, place } => {
|
||||
// This must be done *first*, otherwise the unwind path will see the assignments.
|
||||
if let UnwindAction::Cleanup(unwind) = unwind {
|
||||
propagate(unwind, exit_state);
|
||||
|
@ -496,7 +496,7 @@ impl Direction for Forward {
|
|||
propagate(return_, exit_state);
|
||||
}
|
||||
}
|
||||
TerminatorEdge::SwitchInt { targets, discr } => {
|
||||
TerminatorEdges::SwitchInt { targets, discr } => {
|
||||
let mut applier = ForwardSwitchIntEdgeEffectsApplier {
|
||||
exit_state,
|
||||
targets,
|
||||
|
|
|
@ -34,7 +34,7 @@ use std::cmp::Ordering;
|
|||
|
||||
use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet};
|
||||
use rustc_index::Idx;
|
||||
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdge};
|
||||
use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
mod cursor;
|
||||
|
@ -168,7 +168,7 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
|
|||
state: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx>;
|
||||
) -> TerminatorEdges<'mir, 'tcx>;
|
||||
|
||||
/// Updates the current dataflow state with an effect that occurs immediately *before* the
|
||||
/// given terminator.
|
||||
|
@ -297,7 +297,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx>;
|
||||
) -> TerminatorEdges<'mir, 'tcx>;
|
||||
|
||||
/// See `Analysis::apply_before_terminator_effect`.
|
||||
fn before_terminator_effect(
|
||||
|
@ -356,7 +356,7 @@ where
|
|||
state: &mut A::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
self.terminator_effect(state, terminator, location)
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
|||
state: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
let idx = self.effect(Effect::Primary.at_index(location.statement_index));
|
||||
assert!(state.insert(idx));
|
||||
terminator.edges()
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
self.transfer_function(trans).visit_terminator(terminator, location);
|
||||
terminator.edges()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
|
||||
use rustc_index::Idx;
|
||||
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdge};
|
||||
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
||||
use crate::drop_flag_effects_for_function_entry;
|
||||
|
@ -362,14 +362,14 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
|||
state: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
let mut edges = terminator.edges();
|
||||
if self.skip_unreachable_unwind
|
||||
&& let mir::TerminatorKind::Drop { target, unwind, place, replace: _ } = terminator.kind
|
||||
&& matches!(unwind, mir::UnwindAction::Cleanup(_))
|
||||
&& self.is_unwind_dead(place, state)
|
||||
{
|
||||
edges = TerminatorEdge::Single(target);
|
||||
edges = TerminatorEdges::Single(target);
|
||||
}
|
||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
||||
Self::update_bits(state, path, s)
|
||||
|
@ -491,14 +491,14 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
||||
Self::update_bits(trans, path, s)
|
||||
});
|
||||
if self.skip_unreachable_unwind.contains(location.block) {
|
||||
let mir::TerminatorKind::Drop { target, unwind, .. } = terminator.kind else { bug!() };
|
||||
assert!(matches!(unwind, mir::UnwindAction::Cleanup(_)));
|
||||
TerminatorEdge::Single(target)
|
||||
TerminatorEdges::Single(target)
|
||||
} else {
|
||||
terminator.edges()
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for DefinitelyInitializedPlaces<'_, 'tcx> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
|
||||
Self::update_bits(trans, path, s)
|
||||
});
|
||||
|
@ -702,7 +702,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
let (body, move_data) = (self.body, self.move_data());
|
||||
let term = body[location.block].terminator();
|
||||
let init_loc_map = &move_data.init_loc_map;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{
|
||||
self, CallReturnPlaces, Local, Location, Place, StatementKind, TerminatorEdge,
|
||||
self, CallReturnPlaces, Local, Location, Place, StatementKind, TerminatorEdges,
|
||||
};
|
||||
|
||||
use crate::{Analysis, AnalysisDomain, Backward, GenKill, GenKillAnalysis};
|
||||
|
@ -63,7 +63,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeLiveLocals {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
TransferFunction(trans).visit_terminator(terminator, location);
|
||||
terminator.edges()
|
||||
}
|
||||
|
@ -280,9 +280,9 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeTransitiveLiveLocals<'a> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'mir mir::Terminator<'tcx>,
|
||||
location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
TransferFunction(trans).visit_terminator(terminator, location);
|
||||
TerminatorEdge::None
|
||||
TerminatorEdges::None
|
||||
}
|
||||
|
||||
fn apply_call_return_effect(
|
||||
|
|
|
@ -71,7 +71,7 @@ impl<'tcx, 'a> crate::GenKillAnalysis<'tcx> for MaybeStorageLive<'a> {
|
|||
_trans: &mut Self::Domain,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
_: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
// Terminators have no effect
|
||||
terminator.edges()
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageDead {
|
|||
_: &mut Self::Domain,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
_: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
// Terminators have no effect
|
||||
terminator.edges()
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
|
|||
trans: &mut Self::Domain,
|
||||
terminator: &'t Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) -> TerminatorEdge<'t, 'tcx> {
|
||||
) -> TerminatorEdges<'t, 'tcx> {
|
||||
match terminator.kind {
|
||||
// For call terminators the destination requires storage for the call
|
||||
// and after the call returns successfully, but not after a panic.
|
||||
|
|
|
@ -245,7 +245,7 @@ pub trait ValueAnalysis<'tcx> {
|
|||
&self,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
state: &mut State<Self::Value>,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
self.super_terminator(terminator, state)
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ pub trait ValueAnalysis<'tcx> {
|
|||
&self,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
state: &mut State<Self::Value>,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
match &terminator.kind {
|
||||
TerminatorKind::Call { .. } | TerminatorKind::InlineAsm { .. } => {
|
||||
// Effect is applied by `handle_call_return`.
|
||||
|
@ -306,7 +306,7 @@ pub trait ValueAnalysis<'tcx> {
|
|||
discr: &'mir Operand<'tcx>,
|
||||
targets: &'mir SwitchTargets,
|
||||
state: &mut State<Self::Value>,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
self.super_switch_int(discr, targets, state)
|
||||
}
|
||||
|
||||
|
@ -315,8 +315,8 @@ pub trait ValueAnalysis<'tcx> {
|
|||
discr: &'mir Operand<'tcx>,
|
||||
targets: &'mir SwitchTargets,
|
||||
_state: &mut State<Self::Value>,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
TerminatorEdge::SwitchInt { discr, targets }
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
TerminatorEdges::SwitchInt { discr, targets }
|
||||
}
|
||||
|
||||
fn wrap(self) -> ValueAnalysisWrapper<Self>
|
||||
|
@ -371,11 +371,11 @@ where
|
|||
state: &mut Self::Domain,
|
||||
terminator: &'mir Terminator<'tcx>,
|
||||
_location: Location,
|
||||
) -> TerminatorEdge<'mir, 'tcx> {
|
||||
) -> TerminatorEdges<'mir, 'tcx> {
|
||||
if state.is_reachable() {
|
||||
self.0.handle_terminator(terminator, state)
|
||||
} else {
|
||||
TerminatorEdge::None
|
||||
TerminatorEdges::None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue