pub struct IteratedDominanceFrontier { /* private fields */ }Expand description
The iterated dominance frontiers of a control-flow graph, which tell where SSA (static single assignment) form places phi-nodes.
In SSA form, every assignment to a variable creates a new version of it, and a phi-node merges the
versions where paths of control flow meet. The phi-nodes of a variable go into the iterated
dominance frontier of the blocks that assign it: the dominance frontier of these blocks, then the
dominance frontier of the result, and so on until nothing new is added. A compiler asks this once
per variable, so of prepares the queries once per control-flow graph, and
frontier_of answers them. Here, for the loop variable i of a method
load, whose control flow cfg has the blocks entry and next:
let dominators = Dominators::of(&BiAdjacentGraph::of(&cfg), entry);
let phis = IteratedDominanceFrontier::of(&dominators);
// i is assigned in entry (let mut i = 0) and in next (i += 1)
let phi_blocks = phis.frontier_of(&[entry, next]);
// phi_blocks: [1] - headerUses the algorithm of Sreedhar and Gao. A query walks the subtrees of the dominator tree below the
nodes it is given and the nodes it adds, so its cost depends on the part of the graph it explores,
not on the whole graph. It never builds the dominance frontiers themselves, which can grow
quadratically with the node count;
control_flow::dominance_frontiers returns them as a
graph.
Instances are immutable and safe to share between threads (Send and Sync).
Memory: 16 x node_count bytes, plus the graph of the Dominators, whose arrays it shares -
Java keeps the Dominators themselves reachable.
Implementations§
Source§impl IteratedDominanceFrontier
impl IteratedDominanceFrontier
Sourcepub fn of(dominators: &Dominators) -> IteratedDominanceFrontier
pub fn of(dominators: &Dominators) -> IteratedDominanceFrontier
Returns the iterated dominance frontiers of the graph that dominators were computed on, ready for
queries.
They are prepared anew on every call, not cached: keep the result and query it for every variable.
Time: O(node_count). Memory: 16 x node_count bytes for the result; while it runs, 8 x node_count bytes more.
Sourcepub fn frontier_of(&self, nodes: &[u32]) -> SortedIntView<'static>
pub fn frontier_of(&self, nodes: &[u32]) -> SortedIntView<'static>
Returns the iterated dominance frontier of nodes, in ascending order.
The result can contain given nodes, such as the header of a natural loop, which is in its own dominance frontier. Nodes that the entries do not reach are ignored, and so are duplicates. The result owns its array.
Time: O(nodes.len() + e + (s + k) log(s + k)), where e is the number of nodes and edges the query explores, at most node_count + edge_count; s is the number of distinct given nodes that the entries reach, and k the size of the result. Memory: 4 x k bytes for the result; while it runs, up to about 60 bytes per node the query explores, and nothing sized by the whole graph.
§Panics
With an index out of bounds message if a node is not in 0..node_count; with an
invalid argument message if the query explores more than about 8 x 10^8 nodes.
Trait Implementations§
Source§impl Clone for IteratedDominanceFrontier
impl Clone for IteratedDominanceFrontier
Source§fn clone(&self) -> IteratedDominanceFrontier
fn clone(&self) -> IteratedDominanceFrontier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more