99//! Thomas Lengauer and Robert Endre Tarjan.
1010//! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf>
1111
12- use std:: cmp:: Ordering ;
13-
1412use rustc_index:: { Idx , IndexSlice , IndexVec } ;
1513
1614use super :: ControlFlowGraph ;
@@ -64,9 +62,6 @@ fn is_small_path_graph<G: ControlFlowGraph>(g: &G) -> bool {
6462}
6563
6664fn dominators_impl < G : ControlFlowGraph > ( graph : & G ) -> Inner < G :: Node > {
67- // compute the post order index (rank) for each node
68- let mut post_order_rank = IndexVec :: from_elem_n ( 0 , graph. num_nodes ( ) ) ;
69-
7065 // We allocate capacity for the full set of nodes, because most of the time
7166 // most of the nodes *are* reachable.
7267 let mut parent: IndexVec < PreorderIndex , PreorderIndex > =
@@ -83,12 +78,10 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
8378 pre_order_to_real. push ( graph. start_node ( ) ) ;
8479 parent. push ( PreorderIndex :: ZERO ) ; // the parent of the root node is the root for now.
8580 real_to_pre_order[ graph. start_node ( ) ] = Some ( PreorderIndex :: ZERO ) ;
86- let mut post_order_idx = 0 ;
8781
8882 // Traverse the graph, collecting a number of things:
8983 //
9084 // * Preorder mapping (to it, and back to the actual ordering)
91- // * Postorder mapping (used exclusively for `cmp_in_dominator_order` on the final product)
9285 // * Parents for each vertex in the preorder tree
9386 //
9487 // These are all done here rather than through one of the 'standard'
@@ -104,8 +97,6 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
10497 continue ' recurse;
10598 }
10699 }
107- post_order_rank[ pre_order_to_real[ frame. pre_order_idx ] ] = post_order_idx;
108- post_order_idx += 1 ;
109100
110101 stack. pop ( ) ;
111102 }
@@ -282,7 +273,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
282273
283274 let time = compute_access_time ( start_node, & immediate_dominators) ;
284275
285- Inner { post_order_rank , immediate_dominators, time }
276+ Inner { immediate_dominators, time }
286277}
287278
288279/// Evaluate the link-eval virtual forest, providing the currently minimum semi
@@ -348,7 +339,6 @@ fn compress(
348339/// Tracks the list of dominators for each node.
349340#[ derive( Clone , Debug ) ]
350341struct Inner < N : Idx > {
351- post_order_rank : IndexVec < N , usize > ,
352342 // Even though we track only the immediate dominator of each node, it's
353343 // possible to get its full list of dominators by looking up the dominator
354344 // of each dominator.
@@ -379,17 +369,6 @@ impl<Node: Idx> Dominators<Node> {
379369 }
380370 }
381371
382- /// Provide deterministic ordering of nodes such that, if any two nodes have a dominator
383- /// relationship, the dominator will always precede the dominated. (The relative ordering
384- /// of two unrelated nodes will also be consistent, but otherwise the order has no
385- /// meaning.) This method cannot be used to determine if either Node dominates the other.
386- pub fn cmp_in_dominator_order ( & self , lhs : Node , rhs : Node ) -> Ordering {
387- match & self . kind {
388- Kind :: Path => lhs. index ( ) . cmp ( & rhs. index ( ) ) ,
389- Kind :: General ( g) => g. post_order_rank [ rhs] . cmp ( & g. post_order_rank [ lhs] ) ,
390- }
391- }
392-
393372 /// Returns true if `a` dominates `b`.
394373 ///
395374 /// # Panics
0 commit comments