Skip to content

Remove GenKillAnalysis #131481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add defaults for `Analysis::apply_{call_return_effect,terminator_effe…
…ct}`.

To avoid some low-value boilerplate code.
  • Loading branch information
nnethercote committed Oct 14, 2024
commit 33abf6a0c8b9a051c06dcb43935f3e15c96ade45
12 changes: 1 addition & 11 deletions compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::graph;
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::{
self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
};
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place, TerminatorEdges};
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::fmt::DebugWithContext;
use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
Expand Down Expand Up @@ -595,14 +593,6 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
}
terminator.edges()
}

fn apply_call_return_effect(
&mut self,
_trans: &mut Self::Domain,
_block: mir::BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
}
}

impl<C> DebugWithContext<C> for BorrowIndex {}
17 changes: 10 additions & 7 deletions compiler/rustc_mir_dataflow/src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ pub trait Analysis<'tcx> {
/// initialized here.
fn apply_terminator_effect<'mir>(
&mut self,
state: &mut Self::Domain,
_state: &mut Self::Domain,
terminator: &'mir mir::Terminator<'tcx>,
location: Location,
) -> TerminatorEdges<'mir, 'tcx>;
_location: Location,
) -> TerminatorEdges<'mir, 'tcx> {
terminator.edges()
}

/// Updates the current dataflow state with an effect that occurs immediately *before* the
/// given terminator.
Expand All @@ -192,10 +194,11 @@ pub trait Analysis<'tcx> {
/// edges.
fn apply_call_return_effect(
&mut self,
state: &mut Self::Domain,
block: BasicBlock,
return_places: CallReturnPlaces<'_, 'tcx>,
);
_state: &mut Self::Domain,
_block: BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
}

/// Updates the current dataflow state with the effect of taking a particular branch in a
/// `SwitchInt` terminator.
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_mir_dataflow/src/framework/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,6 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
let idx = self.effect(Effect::Before.at_index(location.statement_index));
assert!(state.insert(idx));
}

fn apply_call_return_effect(
&mut self,
_state: &mut Self::Domain,
_block: BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
self.transfer_function(trans).visit_terminator(terminator, location);
terminator.edges()
}

fn apply_call_return_effect(
&mut self,
_trans: &mut Self::Domain,
_block: BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
}
}

/// A `Visitor` that defines the transfer function for `MaybeBorrowedLocals`.
Expand Down
38 changes: 0 additions & 38 deletions compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,6 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageLive<'a> {
_ => (),
}
}

fn apply_terminator_effect<'mir>(
&mut self,
_trans: &mut Self::Domain,
terminator: &'mir Terminator<'tcx>,
_: Location,
) -> TerminatorEdges<'mir, 'tcx> {
// Terminators have no effect
terminator.edges()
}

fn apply_call_return_effect(
&mut self,
_trans: &mut Self::Domain,
_block: BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
// Nothing to do when a call returns successfully
}
}

pub struct MaybeStorageDead<'a> {
Expand Down Expand Up @@ -113,25 +94,6 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageDead<'a> {
_ => (),
}
}

fn apply_terminator_effect<'mir>(
&mut self,
_: &mut Self::Domain,
terminator: &'mir Terminator<'tcx>,
_: Location,
) -> TerminatorEdges<'mir, 'tcx> {
// Terminators have no effect
terminator.edges()
}

fn apply_call_return_effect(
&mut self,
_trans: &mut Self::Domain,
_block: BasicBlock,
_return_places: CallReturnPlaces<'_, 'tcx>,
) {
// Nothing to do when a call returns successfully
}
}

type BorrowedLocalsResults<'mir, 'tcx> = ResultsCursor<'mir, 'tcx, MaybeBorrowedLocals>;
Expand Down
Loading