Skip to content

Commit

Permalink
Rollup merge of #54213 - nnethercote:keccak-flow_inits-memory, r=niko…
Browse files Browse the repository at this point in the history
…matsakis

De-overlap the lifetimes of `flow_inits` and `flow_{un,ever_}inits`.

This reduces `max-rss` for an `nll-check` build by 27% for `keccak`, and
by 8% for `inflate`.

r? @nikomatsakis
  • Loading branch information
GuillaumeGomez authored Sep 16, 2018
2 parents 4f5ab7f + aa9aca0 commit 937abc9
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,6 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
MaybeInitializedPlaces::new(tcx, mir, &mdpe),
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
));
let flow_uninits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
&attributes,
&dead_unwinds,
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
));
let flow_ever_inits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
&attributes,
&dead_unwinds,
EverInitializedPlaces::new(tcx, mir, &mdpe),
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
));

let locals_are_invalidated_at_exit = match tcx.hir.body_owner_kind(id) {
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false,
Expand All @@ -216,6 +198,12 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
&borrow_set,
&mut errors_buffer,
);

// The various `flow_*` structures can be large. We drop `flow_inits` here
// so it doesn't overlap with the others below. This reduces peak memory
// usage significantly on some benchmarks.
drop(flow_inits);

let regioncx = Rc::new(regioncx);

let flow_borrows = FlowAtLocation::new(do_dataflow(
Expand All @@ -227,6 +215,24 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
Borrows::new(tcx, mir, regioncx.clone(), def_id, body_id, &borrow_set),
|rs, i| DebugFormatted::new(&rs.location(i)),
));
let flow_uninits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
&attributes,
&dead_unwinds,
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
|bd, i| DebugFormatted::new(&bd.move_data().move_paths[i]),
));
let flow_ever_inits = FlowAtLocation::new(do_dataflow(
tcx,
mir,
id,
&attributes,
&dead_unwinds,
EverInitializedPlaces::new(tcx, mir, &mdpe),
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
));

let movable_generator = match tcx.hir.get(id) {
Node::Expr(&hir::Expr {
Expand Down

0 comments on commit 937abc9

Please sign in to comment.