Trim the places that will not be used.

This commit is contained in:
Camille GILLOT 2023-04-24 16:54:11 +00:00
parent 38fa676330
commit 2b0bf3cf59

View File

@ -675,6 +675,15 @@ impl Map {
self.cache_preorder_invoke(place); self.cache_preorder_invoke(place);
} }
} }
// Trim useless places.
for opt_place in self.locals.iter_mut() {
if let Some(place) = *opt_place && self.inner_values[place].is_empty() {
*opt_place = None;
}
}
#[allow(rustc::potential_query_instability)]
self.projections.retain(|_, child| !self.inner_values[*child].is_empty());
} }
/// Potentially register the (local, projection) place and its fields, recursively. /// Potentially register the (local, projection) place and its fields, recursively.
@ -803,7 +812,7 @@ impl Map {
tail_elem: Option<TrackElem>, tail_elem: Option<TrackElem>,
f: &mut impl FnMut(ValueIndex), f: &mut impl FnMut(ValueIndex),
) { ) {
if place.is_indirect() { if place.has_deref() {
// We do not track indirect places. // We do not track indirect places.
return; return;
} }