Skip to content

Commit fef1950

Browse files
committed
Auto merge of #53403 - spastorino:move-out-lazily, r=<try>
[WIP] Do not used Move data flow analysis to see perf wins This commit has the only purposed to be tested by: @bors try If this makes sense I'm gonna do the real work :). When all that happens, this should: Close #53394
2 parents 0f4b498 + f40cde3 commit fef1950

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use dataflow::{FlowAtLocation, MovingOutStatements};
2929
use util::borrowck_errors::{BorrowckErrors, Origin};
3030

3131
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
32+
#[allow(unused)]
3233
pub(super) fn report_use_of_moved_or_uninitialized(
3334
&mut self,
3435
context: Context,
@@ -869,6 +870,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
869870
}
870871

871872
// Retrieve type of a place for the current MIR representation
873+
#[allow(unused)]
872874
fn retrieve_type_for_place(&self, place: &Place<'tcx>) -> Option<ty::Ty> {
873875
match place {
874876
Place::Local(local) => {

src/librustc_mir/borrow_check/flows.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use polonius_engine::Output;
2424
use dataflow::move_paths::indexes::BorrowIndex;
2525
use dataflow::move_paths::HasMoveData;
2626
use dataflow::Borrows;
27-
use dataflow::{EverInitializedPlaces, MovingOutStatements};
27+
use dataflow::{EverInitializedPlaces}; //, MovingOutStatements};
2828
use dataflow::{FlowAtLocation, FlowsAtLocation};
2929
use dataflow::MaybeUninitializedPlaces;
3030
use either::Either;
@@ -35,7 +35,7 @@ use std::rc::Rc;
3535
crate struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
3636
borrows: FlowAtLocation<Borrows<'b, 'gcx, 'tcx>>,
3737
pub uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
38-
pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
38+
//pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
3939
pub ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
4040

4141
/// Polonius Output
@@ -46,14 +46,14 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
4646
crate fn new(
4747
borrows: FlowAtLocation<Borrows<'b, 'gcx, 'tcx>>,
4848
uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
49-
move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
49+
//move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
5050
ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
5151
polonius_output: Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
5252
) -> Self {
5353
Flows {
5454
borrows,
5555
uninits,
56-
move_outs,
56+
//move_outs,
5757
ever_inits,
5858
polonius_output,
5959
}
@@ -79,7 +79,7 @@ macro_rules! each_flow {
7979
($this:ident, $meth:ident($arg:ident)) => {
8080
FlowAtLocation::$meth(&mut $this.borrows, $arg);
8181
FlowAtLocation::$meth(&mut $this.uninits, $arg);
82-
FlowAtLocation::$meth(&mut $this.move_outs, $arg);
82+
//FlowAtLocation::$meth(&mut $this.move_outs, $arg);
8383
FlowAtLocation::$meth(&mut $this.ever_inits, $arg);
8484
};
8585
}
@@ -142,6 +142,7 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
142142
});
143143
s.push_str("] ");
144144

145+
/*
145146
s.push_str("move_out: [");
146147
let mut saw_one = false;
147148
self.move_outs.each_state_bit(|mpi_move_out| {
@@ -153,6 +154,7 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
153154
s.push_str(&format!("{:?}", move_out));
154155
});
155156
s.push_str("] ");
157+
*/
156158

157159
s.push_str("ever_init: [");
158160
let mut saw_one = false;

src/librustc_mir/borrow_check/mod.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use dataflow::DataflowResultsConsumer;
4242
use dataflow::FlowAtLocation;
4343
use dataflow::MoveDataParamEnv;
4444
use dataflow::{do_dataflow, DebugFormatted};
45-
use dataflow::{EverInitializedPlaces, MovingOutStatements};
45+
use dataflow::{EverInitializedPlaces}; //, MovingOutStatements};
4646
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
4747
use util::borrowck_errors::{BorrowckErrors, Origin};
4848

@@ -185,15 +185,15 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
185185
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
186186
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
187187
));
188-
let flow_move_outs = FlowAtLocation::new(do_dataflow(
188+
/*let flow_move_outs = FlowAtLocation::new(do_dataflow(
189189
tcx,
190190
mir,
191191
id,
192192
&attributes,
193193
&dead_unwinds,
194194
MovingOutStatements::new(tcx, mir, &mdpe),
195195
|bd, i| DebugFormatted::new(&bd.move_data().moves[i]),
196-
));
196+
));*/
197197
let flow_ever_inits = FlowAtLocation::new(do_dataflow(
198198
tcx,
199199
mir,
@@ -267,7 +267,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
267267
let mut state = Flows::new(
268268
flow_borrows,
269269
flow_uninits,
270-
flow_move_outs,
270+
//flow_move_outs,
271271
flow_ever_inits,
272272
polonius_output,
273273
);
@@ -407,6 +407,7 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
407407
reservation_error_reported: FxHashSet<Place<'tcx>>,
408408
/// This field keeps track of errors reported in the checking of moved variables,
409409
/// so that we don't report seemingly duplicate errors.
410+
#[allow(unused)]
410411
moved_error_reported: FxHashSet<Place<'tcx>>,
411412
/// Errors to be reported buffer
412413
errors_buffer: Vec<Diagnostic>,
@@ -805,6 +806,7 @@ struct AccessErrorsReported {
805806
}
806807

807808
#[derive(Copy, Clone)]
809+
#[allow(unused)]
808810
enum InitializationRequiringAction {
809811
Update,
810812
Borrow,
@@ -818,6 +820,7 @@ struct RootPlace<'d, 'tcx: 'd> {
818820
}
819821

820822
impl InitializationRequiringAction {
823+
#[allow(unused)]
821824
fn as_noun(self) -> &'static str {
822825
match self {
823826
InitializationRequiringAction::Update => "update",
@@ -827,6 +830,7 @@ impl InitializationRequiringAction {
827830
}
828831
}
829832

833+
#[allow(unused)]
830834
fn as_verb_in_past_tense(self) -> &'static str {
831835
match self {
832836
InitializationRequiringAction::Update => "updated",
@@ -1616,8 +1620,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16161620

16171621
fn check_if_full_path_is_moved(
16181622
&mut self,
1619-
context: Context,
1620-
desired_action: InitializationRequiringAction,
1623+
_context: Context,
1624+
_desired_action: InitializationRequiringAction,
16211625
place_span: (&Place<'tcx>, Span),
16221626
flow_state: &Flows<'cx, 'gcx, 'tcx>,
16231627
) {
@@ -1626,7 +1630,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16261630
let place = self.base_path(place_span.0);
16271631

16281632
let maybe_uninits = &flow_state.uninits;
1629-
let curr_move_outs = &flow_state.move_outs;
1633+
//let curr_move_outs = &flow_state.move_outs;
16301634

16311635
// Bad scenarios:
16321636
//
@@ -1667,13 +1671,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16671671
match self.move_path_closest_to(place) {
16681672
Ok(mpi) => {
16691673
if maybe_uninits.contains(&mpi) {
1670-
self.report_use_of_moved_or_uninitialized(
1674+
/*self.report_use_of_moved_or_uninitialized(
16711675
context,
16721676
desired_action,
16731677
place_span,
16741678
mpi,
16751679
curr_move_outs,
1676-
);
1680+
);*/
16771681
return; // don't bother finding other problems.
16781682
}
16791683
}
@@ -1700,7 +1704,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17001704
let place = self.base_path(place_span.0);
17011705

17021706
let maybe_uninits = &flow_state.uninits;
1703-
let curr_move_outs = &flow_state.move_outs;
1707+
//let curr_move_outs = &flow_state.move_outs;
17041708

17051709
// Bad scenarios:
17061710
//
@@ -1730,14 +1734,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17301734

17311735
debug!("check_if_path_or_subpath_is_moved place: {:?}", place);
17321736
if let Some(mpi) = self.move_path_for_place(place) {
1733-
if let Some(child_mpi) = maybe_uninits.has_any_child_of(mpi) {
1737+
if let Some(_child_mpi) = maybe_uninits.has_any_child_of(mpi) {
1738+
/*
17341739
self.report_use_of_moved_or_uninitialized(
17351740
context,
17361741
desired_action,
17371742
place_span,
17381743
child_mpi,
17391744
curr_move_outs,
17401745
);
1746+
*/
17411747
return; // don't bother finding other problems.
17421748
}
17431749
}

0 commit comments

Comments
 (0)