Skip to content

Commit

Permalink
liveness: stop materializing facts that placeholders are live at all …
Browse files Browse the repository at this point in the history
…points
  • Loading branch information
lqd committed Dec 22, 2020
1 parent d8cb41f commit 1360908
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
20 changes: 2 additions & 18 deletions polonius-engine/src/output/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! An implementation of the origin liveness calculation logic

use std::collections::BTreeSet;
use std::time::Instant;

use crate::facts::FactTypes;
Expand All @@ -23,7 +22,7 @@ pub(super) fn compute_live_origins<T: FactTypes>(
cfg_edge: &Relation<(T::Point, T::Point)>,
var_maybe_partly_initialized_on_exit: Relation<(T::Variable, T::Point)>,
output: &mut Output<T>,
) -> Vec<(T::Origin, T::Point)> {
) -> Relation<(T::Origin, T::Point)> {
let timer = Instant::now();
let mut iteration = Iteration::new();

Expand Down Expand Up @@ -151,20 +150,5 @@ pub(super) fn compute_live_origins<T: FactTypes>(
}
}

origin_live_on_entry.elements
}

pub(super) fn make_universal_regions_live<T: FactTypes>(
origin_live_on_entry: &mut Vec<(T::Origin, T::Point)>,
cfg_node: &BTreeSet<T::Point>,
universal_regions: &[T::Origin],
) {
debug!("make_universal_regions_live()");

origin_live_on_entry.reserve(universal_regions.len() * cfg_node.len());
for &origin in universal_regions.iter() {
for &point in cfg_node.iter() {
origin_live_on_entry.push((origin, point));
}
}
origin_live_on_entry
}
16 changes: 1 addition & 15 deletions polonius-engine/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,13 @@ impl<T: FactTypes> Output<T> {
drop_of_var_derefs_origin: all_facts.drop_of_var_derefs_origin.clone(),
};

let mut origin_live_on_entry = liveness::compute_live_origins(
let origin_live_on_entry = liveness::compute_live_origins(
liveness_ctx,
&cfg_edge,
var_maybe_partly_initialized_on_exit,
&mut result,
);

let cfg_node = cfg_edge
.iter()
.map(|&(point1, _)| point1)
.chain(cfg_edge.iter().map(|&(_, point2)| point2))
.collect();

liveness::make_universal_regions_live::<T>(
&mut origin_live_on_entry,
&cfg_node,
&all_facts.universal_region,
);

// 3) Borrow checking

// Prepare data as datafrog relations, ready to join.
Expand All @@ -222,8 +210,6 @@ impl<T: FactTypes> Output<T> {
// analysis. If these facts happened to be recorded in separate MIR walks, we might also
// avoid generating those facts.

let origin_live_on_entry = origin_live_on_entry.into();

// TODO: also flip the order of this relation's arguments in rustc
// from `loan_invalidated_at(point, loan)` to `loan_invalidated_at(loan, point)`.
// to avoid this allocation.
Expand Down

0 comments on commit 1360908

Please sign in to comment.