Skip to content

Commit 3900bf8

Browse files
committed
Auto merge of #52612 - matthewjasper:remove-unnecessary-flow, r=nikomatsakis
Don't keep the possibly initialized flow around longer than needed The possibly initialized flow isn't used after liveness is computed, so don't keep it around. Locally this is about a 10% time win for tuple-stress (which is spending a lot of time calculating flows now that it's not spending so much on liveness). r? @nikomatsakis
2 parents 210d61f + 1d912bf commit 3900bf8

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

src/librustc_mir/borrow_check/flows.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ use dataflow::move_paths::HasMoveData;
2626
use dataflow::Borrows;
2727
use dataflow::{EverInitializedPlaces, MovingOutStatements};
2828
use dataflow::{FlowAtLocation, FlowsAtLocation};
29-
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
29+
use dataflow::MaybeUninitializedPlaces;
3030
use either::Either;
3131
use std::fmt;
3232
use std::rc::Rc;
3333

3434
// (forced to be `pub` due to its use as an associated type below.)
3535
crate struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
3636
borrows: FlowAtLocation<Borrows<'b, 'gcx, 'tcx>>,
37-
pub inits: FlowAtLocation<MaybeInitializedPlaces<'b, 'gcx, 'tcx>>,
3837
pub uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
3938
pub move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
4039
pub ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
@@ -46,15 +45,13 @@ crate struct Flows<'b, 'gcx: 'tcx, 'tcx: 'b> {
4645
impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
4746
crate fn new(
4847
borrows: FlowAtLocation<Borrows<'b, 'gcx, 'tcx>>,
49-
inits: FlowAtLocation<MaybeInitializedPlaces<'b, 'gcx, 'tcx>>,
5048
uninits: FlowAtLocation<MaybeUninitializedPlaces<'b, 'gcx, 'tcx>>,
5149
move_outs: FlowAtLocation<MovingOutStatements<'b, 'gcx, 'tcx>>,
5250
ever_inits: FlowAtLocation<EverInitializedPlaces<'b, 'gcx, 'tcx>>,
5351
polonius_output: Option<Rc<Output<RegionVid, BorrowIndex, LocationIndex>>>,
5452
) -> Self {
5553
Flows {
5654
borrows,
57-
inits,
5855
uninits,
5956
move_outs,
6057
ever_inits,
@@ -81,7 +78,6 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
8178
macro_rules! each_flow {
8279
($this:ident, $meth:ident($arg:ident)) => {
8380
FlowAtLocation::$meth(&mut $this.borrows, $arg);
84-
FlowAtLocation::$meth(&mut $this.inits, $arg);
8581
FlowAtLocation::$meth(&mut $this.uninits, $arg);
8682
FlowAtLocation::$meth(&mut $this.move_outs, $arg);
8783
FlowAtLocation::$meth(&mut $this.ever_inits, $arg);
@@ -134,18 +130,6 @@ impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
134130
});
135131
s.push_str("] ");
136132

137-
s.push_str("inits: [");
138-
let mut saw_one = false;
139-
self.inits.each_state_bit(|mpi_init| {
140-
if saw_one {
141-
s.push_str(", ");
142-
};
143-
saw_one = true;
144-
let move_path = &self.inits.operator().move_data().move_paths[mpi_init];
145-
s.push_str(&format!("{}", move_path));
146-
});
147-
s.push_str("] ");
148-
149133
s.push_str("uninits: [");
150134
let mut saw_one = false;
151135
self.uninits.each_state_bit(|mpi_uninit| {

src/librustc_mir/borrow_check/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
216216
&borrow_set,
217217
);
218218
let regioncx = Rc::new(regioncx);
219-
let flow_inits = flow_inits; // remove mut
220219

221220
let flow_borrows = FlowAtLocation::new(do_dataflow(
222221
tcx,
@@ -262,7 +261,6 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
262261

263262
let mut state = Flows::new(
264263
flow_borrows,
265-
flow_inits,
266264
flow_uninits,
267265
flow_move_outs,
268266
flow_ever_inits,

0 commit comments

Comments
 (0)