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