Skip to content

Commit 500e55b

Browse files
committed
Remove uses of ResultsClonedCursor.
By just cloning the entire `Results` in the one place where `ResultsClonedCursor` was used. This is extra allocations but the performance effect is negligible.
1 parent 5f5263b commit 500e55b

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Diff for: compiler/rustc_mir_dataflow/src/framework/engine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use super::{
3131
pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
3232

3333
/// A dataflow analysis that has converged to fixpoint.
34+
#[derive(Clone)]
3435
pub struct Results<'tcx, A, E = EntrySets<'tcx, A>>
3536
where
3637
A: Analysis<'tcx>,

Diff for: compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::mir::*;
55
use std::borrow::Cow;
66

77
use super::MaybeBorrowedLocals;
8-
use crate::{GenKill, ResultsClonedCursor};
8+
use crate::{GenKill, ResultsCursor};
99

1010
#[derive(Clone)]
1111
pub struct MaybeStorageLive<'a> {
@@ -152,22 +152,21 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageDead {
152152
}
153153
}
154154

155-
type BorrowedLocalsResults<'res, 'mir, 'tcx> =
156-
ResultsClonedCursor<'res, 'mir, 'tcx, MaybeBorrowedLocals>;
155+
type BorrowedLocalsResults<'mir, 'tcx> = ResultsCursor<'mir, 'tcx, MaybeBorrowedLocals>;
157156

158157
/// Dataflow analysis that determines whether each local requires storage at a
159158
/// given location; i.e. whether its storage can go away without being observed.
160-
pub struct MaybeRequiresStorage<'res, 'mir, 'tcx> {
161-
borrowed_locals: BorrowedLocalsResults<'res, 'mir, 'tcx>,
159+
pub struct MaybeRequiresStorage<'mir, 'tcx> {
160+
borrowed_locals: BorrowedLocalsResults<'mir, 'tcx>,
162161
}
163162

164-
impl<'res, 'mir, 'tcx> MaybeRequiresStorage<'res, 'mir, 'tcx> {
165-
pub fn new(borrowed_locals: BorrowedLocalsResults<'res, 'mir, 'tcx>) -> Self {
163+
impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> {
164+
pub fn new(borrowed_locals: BorrowedLocalsResults<'mir, 'tcx>) -> Self {
166165
MaybeRequiresStorage { borrowed_locals }
167166
}
168167
}
169168

170-
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
169+
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
171170
type Domain = BitSet<Local>;
172171

173172
const NAME: &'static str = "requires_storage";
@@ -186,7 +185,7 @@ impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
186185
}
187186
}
188187

189-
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
188+
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
190189
type Idx = Local;
191190

192191
fn domain_size(&self, body: &Body<'tcx>) -> usize {
@@ -343,7 +342,7 @@ impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'_, '_, 'tcx> {
343342
}
344343
}
345344

346-
impl<'tcx> MaybeRequiresStorage<'_, '_, 'tcx> {
345+
impl<'tcx> MaybeRequiresStorage<'_, 'tcx> {
347346
/// Kill locals that are fully moved and have not been borrowed.
348347
fn check_for_move(&mut self, trans: &mut impl GenKill<Local>, loc: Location) {
349348
let body = self.borrowed_locals.body();
@@ -352,12 +351,12 @@ impl<'tcx> MaybeRequiresStorage<'_, '_, 'tcx> {
352351
}
353352
}
354353

355-
struct MoveVisitor<'a, 'res, 'mir, 'tcx, T> {
356-
borrowed_locals: &'a mut BorrowedLocalsResults<'res, 'mir, 'tcx>,
354+
struct MoveVisitor<'a, 'mir, 'tcx, T> {
355+
borrowed_locals: &'a mut BorrowedLocalsResults<'mir, 'tcx>,
357356
trans: &'a mut T,
358357
}
359358

360-
impl<'tcx, T> Visitor<'tcx> for MoveVisitor<'_, '_, '_, 'tcx, T>
359+
impl<'tcx, T> Visitor<'tcx> for MoveVisitor<'_, '_, 'tcx, T>
361360
where
362361
T: GenKill<Local>,
363362
{

Diff for: compiler/rustc_mir_dataflow/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use self::framework::{
2424
fmt, lattice, visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis,
2525
JoinSemiLattice, MaybeReachable, Results, ResultsCursor, ResultsVisitable, ResultsVisitor,
2626
};
27-
use self::framework::{Backward, ResultsClonedCursor, SwitchIntEdgeEffects};
27+
use self::framework::{Backward, SwitchIntEdgeEffects};
2828
use self::move_paths::MoveData;
2929

3030
pub mod debuginfo;

Diff for: compiler/rustc_mir_transform/src/coroutine.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,12 @@ fn locals_live_across_suspend_points<'tcx>(
680680
let borrowed_locals_results =
681681
MaybeBorrowedLocals.into_engine(tcx, body).pass_name("coroutine").iterate_to_fixpoint();
682682

683-
let mut borrowed_locals_cursor = borrowed_locals_results.cloned_results_cursor(body);
683+
let mut borrowed_locals_cursor = borrowed_locals_results.clone().into_results_cursor(body);
684684

685685
// Calculate the MIR locals that we actually need to keep storage around
686686
// for.
687687
let mut requires_storage_cursor =
688-
MaybeRequiresStorage::new(borrowed_locals_results.cloned_results_cursor(body))
688+
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
689689
.into_engine(tcx, body)
690690
.iterate_to_fixpoint()
691691
.into_results_cursor(body);
@@ -829,7 +829,7 @@ fn compute_storage_conflicts<'mir, 'tcx>(
829829
body: &'mir Body<'tcx>,
830830
saved_locals: &CoroutineSavedLocals,
831831
always_live_locals: BitSet<Local>,
832-
mut requires_storage: rustc_mir_dataflow::Results<'tcx, MaybeRequiresStorage<'_, 'mir, 'tcx>>,
832+
mut requires_storage: rustc_mir_dataflow::Results<'tcx, MaybeRequiresStorage<'mir, 'tcx>>,
833833
) -> BitMatrix<CoroutineSavedLocal, CoroutineSavedLocal> {
834834
assert_eq!(body.local_decls.len(), saved_locals.domain_size());
835835

0 commit comments

Comments
 (0)