1
Fork 0

Implement SSA-based reference propagation.

This commit is contained in:
Camille GILLOT 2022-12-04 18:26:09 +00:00
parent f7b831ac8a
commit 3490375570
21 changed files with 2668 additions and 80 deletions

View file

@ -1524,6 +1524,19 @@ impl<V, T> ProjectionElem<V, T> {
}
}
/// Returns `true` if the target of this projection always refers to the same memory region
/// whatever the state of the program.
pub fn is_stable_offset(&self) -> bool {
match self {
Self::Deref | Self::Index(_) => false,
Self::Field(_, _)
| Self::OpaqueCast(_)
| Self::ConstantIndex { .. }
| Self::Subslice { .. }
| Self::Downcast(_, _) => true,
}
}
/// Returns `true` if this is a `Downcast` projection with the given `VariantIdx`.
pub fn is_downcast_to(&self, v: VariantIdx) -> bool {
matches!(*self, Self::Downcast(_, x) if x == v)