@@ -84,7 +84,7 @@ impl<'tcx> crate::MirPass<'tcx> for JumpThreading {
8484 body,
8585 arena,
8686 map : Map :: new ( tcx, body, Some ( MAX_PLACES ) ) ,
87- maybe_loop_headers : maybe_loop_headers ( body) ,
87+ maybe_loop_headers : loops :: maybe_loop_headers ( body) ,
8888 opportunities : Vec :: new ( ) ,
8989 } ;
9090
@@ -830,29 +830,3 @@ enum Update {
830830 Incr ,
831831 Decr ,
832832}
833-
834- /// Compute the set of loop headers in the given body. A loop header is usually defined as a block
835- /// which dominates one of its predecessors. This definition is only correct for reducible CFGs.
836- /// However, computing dominators is expensive, so we approximate according to the post-order
837- /// traversal order. A loop header for us is a block which is visited after its predecessor in
838- /// post-order. This is ok as we mostly need a heuristic.
839- fn maybe_loop_headers ( body : & Body < ' _ > ) -> DenseBitSet < BasicBlock > {
840- let mut maybe_loop_headers = DenseBitSet :: new_empty ( body. basic_blocks . len ( ) ) ;
841- let mut visited = DenseBitSet :: new_empty ( body. basic_blocks . len ( ) ) ;
842- for ( bb, bbdata) in traversal:: postorder ( body) {
843- // Post-order means we visit successors before the block for acyclic CFGs.
844- // If the successor is not visited yet, consider it a loop header.
845- for succ in bbdata. terminator ( ) . successors ( ) {
846- if !visited. contains ( succ) {
847- maybe_loop_headers. insert ( succ) ;
848- }
849- }
850-
851- // Only mark `bb` as visited after we checked the successors, in case we have a self-loop.
852- // bb1: goto -> bb1;
853- let _new = visited. insert ( bb) ;
854- debug_assert ! ( _new) ;
855- }
856-
857- maybe_loop_headers
858- }
0 commit comments