Skip to content

Commit

Permalink
Remove Allocations.
Browse files Browse the repository at this point in the history
It's not necessary, and just complicates things.
  • Loading branch information
nnethercote committed Aug 29, 2024
1 parent 0a282ea commit ad5a6e1
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions compiler/rustc_mir_transform/src/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {

fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let def_id = body.source.def_id();
let mut allocations = Allocations::default();
let mut candidates = FxIndexMap::default();
let mut candidates_reverse = FxIndexMap::default();
let mut write_info = WriteInfo::default();
trace!(func = ?tcx.def_path_str(def_id));

Expand Down Expand Up @@ -196,8 +197,8 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
let mut candidates = find_candidates(
body,
&borrowed,
&mut allocations.candidates,
&mut allocations.candidates_reverse,
&mut candidates,
&mut candidates_reverse,
);
trace!(?candidates);
dest_prop_mir_dump(tcx, body, &points, &live, round_count);
Expand Down Expand Up @@ -255,17 +256,6 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
}
}

/// Container for the various allocations that we need.
///
/// We store these here and hand out `&mut` access to them, instead of dropping and recreating them
/// frequently. Everything with a `&'alloc` lifetime points into here.
#[derive(Default)]
struct Allocations {
candidates: FxIndexMap<Local, Vec<Local>>,
candidates_reverse: FxIndexMap<Local, Vec<Local>>,
// PERF: Do this for `MaybeLiveLocals` allocations too.
}

#[derive(Debug)]
struct Candidates<'alloc> {
/// The set of candidates we are considering in this optimization.
Expand Down

0 comments on commit ad5a6e1

Please sign in to comment.