@@ -67,7 +67,7 @@ use crate::transform::{MirPass, MirSource};
6767use crate :: transform:: simplify;
6868use crate :: transform:: no_landing_pads:: no_landing_pads;
6969use crate :: dataflow:: { DataflowResults , DataflowResultsConsumer , FlowAtLocation } ;
70- use crate :: dataflow:: { do_dataflow, DebugFormatted , state_for_location } ;
70+ use crate :: dataflow:: { do_dataflow, DebugFormatted , DataflowResultsCursor } ;
7171use crate :: dataflow:: { MaybeStorageLive , HaveBeenBorrowedLocals , RequiresStorage } ;
7272use crate :: util:: dump_mir;
7373use crate :: util:: liveness;
@@ -436,9 +436,10 @@ fn locals_live_across_suspend_points(
436436 // Calculate when MIR locals have live storage. This gives us an upper bound of their
437437 // lifetimes.
438438 let storage_live_analysis = MaybeStorageLive :: new ( body) ;
439- let storage_live =
439+ let storage_live_results =
440440 do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, storage_live_analysis,
441441 |bd, p| DebugFormatted :: new ( & bd. body ( ) . local_decls [ p] ) ) ;
442+ let mut storage_live_cursor = DataflowResultsCursor :: new ( & storage_live_results, body) ;
442443
443444 // Find the MIR locals which do not use StorageLive/StorageDead statements.
444445 // The storage of these locals are always live.
@@ -448,17 +449,18 @@ fn locals_live_across_suspend_points(
448449 // Calculate the MIR locals which have been previously
449450 // borrowed (even if they are still active).
450451 let borrowed_locals_analysis = HaveBeenBorrowedLocals :: new ( body) ;
451- let borrowed_locals_result =
452+ let borrowed_locals_results =
452453 do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, borrowed_locals_analysis,
453454 |bd, p| DebugFormatted :: new ( & bd. body ( ) . local_decls [ p] ) ) ;
455+ let mut borrowed_locals_cursor = DataflowResultsCursor :: new ( & borrowed_locals_results, body) ;
454456
455457 // Calculate the MIR locals that we actually need to keep storage around
456458 // for.
457- let requires_storage_analysis = RequiresStorage :: new ( body, & borrowed_locals_result ) ;
458- let requires_storage =
459+ let requires_storage_analysis = RequiresStorage :: new ( body, & borrowed_locals_results ) ;
460+ let requires_storage_results =
459461 do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, requires_storage_analysis,
460462 |bd, p| DebugFormatted :: new ( & bd. body ( ) . local_decls [ p] ) ) ;
461- let requires_storage_analysis = RequiresStorage :: new ( body , & borrowed_locals_result ) ;
463+ let mut requires_storage_cursor = DataflowResultsCursor :: new ( & requires_storage_results , body ) ;
462464
463465 // Calculate the liveness of MIR locals ignoring borrows.
464466 let mut live_locals = liveness:: LiveVarSet :: new_empty ( body. local_decls . len ( ) ) ;
@@ -484,10 +486,6 @@ fn locals_live_across_suspend_points(
484486 } ;
485487
486488 if !movable {
487- let borrowed_locals = state_for_location ( loc,
488- & borrowed_locals_analysis,
489- & borrowed_locals_result,
490- body) ;
491489 // The `liveness` variable contains the liveness of MIR locals ignoring borrows.
492490 // This is correct for movable generators since borrows cannot live across
493491 // suspension points. However for immovable generators we need to account for
@@ -498,22 +496,19 @@ fn locals_live_across_suspend_points(
498496 // If a borrow is converted to a raw reference, we must also assume that it lives
499497 // forever. Note that the final liveness is still bounded by the storage liveness
500498 // of the local, which happens using the `intersect` operation below.
501- liveness. outs [ block] . union ( & borrowed_locals) ;
499+ borrowed_locals_cursor. seek ( loc) ;
500+ liveness. outs [ block] . union ( borrowed_locals_cursor. get ( ) ) ;
502501 }
503502
504- let storage_liveness = state_for_location ( loc,
505- & storage_live_analysis,
506- & storage_live,
507- body) ;
503+ storage_live_cursor. seek ( loc) ;
504+ let storage_liveness = storage_live_cursor. get ( ) ;
508505
509506 // Store the storage liveness for later use so we can restore the state
510507 // after a suspension point
511508 storage_liveness_map. insert ( block, storage_liveness. clone ( ) ) ;
512509
513- let mut storage_required = state_for_location ( loc,
514- & requires_storage_analysis,
515- & requires_storage,
516- body) ;
510+ requires_storage_cursor. seek ( loc) ;
511+ let mut storage_required = requires_storage_cursor. get ( ) . clone ( ) ;
517512
518513 // Mark locals without storage statements as always requiring storage
519514 storage_required. union ( & ignored. 0 ) ;
@@ -549,8 +544,7 @@ fn locals_live_across_suspend_points(
549544 body,
550545 & live_locals,
551546 & ignored,
552- requires_storage,
553- requires_storage_analysis) ;
547+ requires_storage_results) ;
554548
555549 LivenessInfo {
556550 live_locals,
@@ -588,7 +582,6 @@ fn compute_storage_conflicts(
588582 stored_locals : & liveness:: LiveVarSet ,
589583 ignored : & StorageIgnored ,
590584 requires_storage : DataflowResults < ' tcx , RequiresStorage < ' mir , ' tcx > > ,
591- _requires_storage_analysis : RequiresStorage < ' mir , ' tcx > ,
592585) -> BitMatrix < GeneratorSavedLocal , GeneratorSavedLocal > {
593586 assert_eq ! ( body. local_decls. len( ) , ignored. 0 . domain_size( ) ) ;
594587 assert_eq ! ( body. local_decls. len( ) , stored_locals. domain_size( ) ) ;
0 commit comments