@@ -537,29 +537,29 @@ impl TraverseCoverageGraphWithLoops {
537
537
"TraverseCoverageGraphWithLoops::next - context_stack: {:?}" ,
538
538
self . context_stack. iter( ) . rev( ) . collect:: <Vec <_>>( )
539
539
) ;
540
- while let Some ( next_bcb) = {
541
- // Strip contexts with empty worklists from the top of the stack
542
- while self . context_stack . last ( ) . map_or ( false , |context| context. worklist . is_empty ( ) ) {
540
+
541
+ while let Some ( context) = self . context_stack . last_mut ( ) {
542
+ if let Some ( next_bcb) = context. worklist . pop ( ) {
543
+ if !self . visited . insert ( next_bcb) {
544
+ debug ! ( "Already visited: {:?}" , next_bcb) ;
545
+ continue ;
546
+ }
547
+ debug ! ( "Visiting {:?}" , next_bcb) ;
548
+ if self . backedges [ next_bcb] . len ( ) > 0 {
549
+ debug ! ( "{:?} is a loop header! Start a new TraversalContext..." , next_bcb) ;
550
+ self . context_stack . push ( TraversalContext {
551
+ loop_backedges : Some ( ( self . backedges [ next_bcb] . clone ( ) , next_bcb) ) ,
552
+ worklist : Vec :: new ( ) ,
553
+ } ) ;
554
+ }
555
+ self . extend_worklist ( basic_coverage_blocks, next_bcb) ;
556
+ return Some ( next_bcb) ;
557
+ } else {
558
+ // Strip contexts with empty worklists from the top of the stack
543
559
self . context_stack . pop ( ) ;
544
560
}
545
- // Pop the next bcb off of the current context_stack. If none, all BCBs were visited.
546
- self . context_stack . last_mut ( ) . map_or ( None , |context| context. worklist . pop ( ) )
547
- } {
548
- if !self . visited . insert ( next_bcb) {
549
- debug ! ( "Already visited: {:?}" , next_bcb) ;
550
- continue ;
551
- }
552
- debug ! ( "Visiting {:?}" , next_bcb) ;
553
- if self . backedges [ next_bcb] . len ( ) > 0 {
554
- debug ! ( "{:?} is a loop header! Start a new TraversalContext..." , next_bcb) ;
555
- self . context_stack . push ( TraversalContext {
556
- loop_backedges : Some ( ( self . backedges [ next_bcb] . clone ( ) , next_bcb) ) ,
557
- worklist : Vec :: new ( ) ,
558
- } ) ;
559
- }
560
- self . extend_worklist ( basic_coverage_blocks, next_bcb) ;
561
- return Some ( next_bcb) ;
562
561
}
562
+
563
563
None
564
564
}
565
565
0 commit comments