summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_dataflow/src/value_analysis.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /compiler/rustc_mir_dataflow/src/value_analysis.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/value_analysis.rs')
-rw-r--r--compiler/rustc_mir_dataflow/src/value_analysis.rs41
1 files changed, 7 insertions, 34 deletions
diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs
index 025d2ddfd..2802f5491 100644
--- a/compiler/rustc_mir_dataflow/src/value_analysis.rs
+++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs
@@ -332,8 +332,6 @@ pub struct ValueAnalysisWrapper<T>(pub T);
impl<'tcx, T: ValueAnalysis<'tcx>> AnalysisDomain<'tcx> for ValueAnalysisWrapper<T> {
type Domain = State<T::Value>;
- type Direction = crate::Forward;
-
const NAME: &'static str = T::NAME;
fn bottom_value(&self, _body: &Body<'tcx>) -> Self::Domain {
@@ -476,26 +474,10 @@ impl<V: Clone> State<V> {
}
}
- pub fn is_reachable(&self) -> bool {
+ fn is_reachable(&self) -> bool {
matches!(&self.0, StateData::Reachable(_))
}
- pub fn mark_unreachable(&mut self) {
- self.0 = StateData::Unreachable;
- }
-
- pub fn flood_all(&mut self)
- where
- V: HasTop,
- {
- self.flood_all_with(V::TOP)
- }
-
- pub fn flood_all_with(&mut self, value: V) {
- let StateData::Reachable(values) = &mut self.0 else { return };
- values.raw.fill(value);
- }
-
/// Assign `value` to all places that are contained in `place` or may alias one.
pub fn flood_with(&mut self, place: PlaceRef<'_>, map: &Map, value: V) {
self.flood_with_tail_elem(place, None, map, value)
@@ -510,7 +492,7 @@ impl<V: Clone> State<V> {
}
/// Assign `value` to the discriminant of `place` and all places that may alias it.
- pub fn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map, value: V) {
+ fn flood_discr_with(&mut self, place: PlaceRef<'_>, map: &Map, value: V) {
self.flood_with_tail_elem(place, Some(TrackElem::Discriminant), map, value)
}
@@ -546,7 +528,7 @@ impl<V: Clone> State<V> {
/// This does nothing if the place is not tracked.
///
/// The target place must have been flooded before calling this method.
- pub fn insert_idx(&mut self, target: PlaceIndex, result: ValueOrPlace<V>, map: &Map) {
+ fn insert_idx(&mut self, target: PlaceIndex, result: ValueOrPlace<V>, map: &Map) {
match result {
ValueOrPlace::Value(value) => self.insert_value_idx(target, value, map),
ValueOrPlace::Place(source) => self.insert_place_idx(target, source, map),
@@ -841,7 +823,7 @@ impl Map {
) {
// Allocate a value slot if it doesn't have one, and the user requested one.
assert!(self.places[place].value_index.is_none());
- if tcx.layout_of(param_env.and(ty)).map_or(false, |layout| layout.abi.is_scalar()) {
+ if tcx.layout_of(param_env.and(ty)).is_ok_and(|layout| layout.abi.is_scalar()) {
self.places[place].value_index = Some(self.value_count.into());
self.value_count += 1;
}
@@ -910,18 +892,13 @@ impl Map {
self.inner_values[root] = start..end;
}
- /// Returns the number of tracked places, i.e., those for which a value can be stored.
- pub fn tracked_places(&self) -> usize {
- self.value_count
- }
-
/// Applies a single projection element, yielding the corresponding child.
pub fn apply(&self, place: PlaceIndex, elem: TrackElem) -> Option<PlaceIndex> {
self.projections.get(&(place, elem)).copied()
}
/// Locates the given place, if it exists in the tree.
- pub fn find_extra(
+ fn find_extra(
&self,
place: PlaceRef<'_>,
extra: impl IntoIterator<Item = TrackElem>,
@@ -954,7 +931,7 @@ impl Map {
}
/// Iterate over all direct children.
- pub fn children(&self, parent: PlaceIndex) -> impl Iterator<Item = PlaceIndex> + '_ {
+ fn children(&self, parent: PlaceIndex) -> impl Iterator<Item = PlaceIndex> + '_ {
Children::new(self, parent)
}
@@ -979,11 +956,7 @@ impl Map {
// The local is not tracked at all, so it does not alias anything.
return;
};
- let elems = place
- .projection
- .iter()
- .map(|&elem| elem.try_into())
- .chain(tail_elem.map(Ok).into_iter());
+ let elems = place.projection.iter().map(|&elem| elem.try_into()).chain(tail_elem.map(Ok));
for elem in elems {
// A field aliases the parent place.
if let Some(vi) = self.places[index].value_index {