mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
Add sctrictly_dominates method
This commit is contained in:
@@ -386,6 +386,24 @@ pub fn dominates(&self, a: Node, b: Node) -> bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if `a` **strictly** dominates `b`
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `b` is unreachable
|
||||
#[inline]
|
||||
pub fn strictly_dominates(&self, a: Node, b: Node) -> bool {
|
||||
match &self.kind {
|
||||
Kind::Path => a.index() < b.index(),
|
||||
Kind::General(g) => {
|
||||
let a = g.time[a];
|
||||
let b = g.time[b];
|
||||
assert!(b.start != 0, "node {b:?} is not reachable");
|
||||
a.start < b.start && b.finish < a.finish
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the number of vertices discovered at the time when processing of a particular vertex
|
||||
|
||||
@@ -1609,6 +1609,11 @@ pub fn dominates(&self, other: Location, dominators: &Dominators<BasicBlock>) ->
|
||||
dominators.dominates(self.block, other.block)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn strictly_dominates(&self, other: Location, dominators: &Dominators<BasicBlock>) -> bool {
|
||||
self.block != other.block && dominators.strictly_dominates(self.block, other.block)
|
||||
}
|
||||
}
|
||||
|
||||
/// `DefLocation` represents the location of a definition - either an argument or an assignment
|
||||
|
||||
Reference in New Issue
Block a user