@@ -67,7 +67,7 @@ use crate::transform::{MirPass, MirSource};
67
67
use crate :: transform:: simplify;
68
68
use crate :: transform:: no_landing_pads:: no_landing_pads;
69
69
use crate :: dataflow:: { DataflowResults , DataflowResultsConsumer , FlowAtLocation } ;
70
- use crate :: dataflow:: { do_dataflow, DebugFormatted , state_for_location } ;
70
+ use crate :: dataflow:: { do_dataflow, DebugFormatted , DataflowResultsCursor } ;
71
71
use crate :: dataflow:: { MaybeStorageLive , HaveBeenBorrowedLocals , RequiresStorage } ;
72
72
use crate :: util:: dump_mir;
73
73
use crate :: util:: liveness;
@@ -436,9 +436,10 @@ fn locals_live_across_suspend_points(
436
436
// Calculate when MIR locals have live storage. This gives us an upper bound of their
437
437
// lifetimes.
438
438
let storage_live_analysis = MaybeStorageLive :: new ( body) ;
439
- let storage_live =
439
+ let storage_live_results =
440
440
do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, storage_live_analysis,
441
441
|bd, p| DebugFormatted :: new ( & bd. body ( ) . local_decls [ p] ) ) ;
442
+ let mut storage_live_cursor = DataflowResultsCursor :: new ( & storage_live_results, body) ;
442
443
443
444
// Find the MIR locals which do not use StorageLive/StorageDead statements.
444
445
// The storage of these locals are always live.
@@ -448,17 +449,18 @@ fn locals_live_across_suspend_points(
448
449
// Calculate the MIR locals which have been previously
449
450
// borrowed (even if they are still active).
450
451
let borrowed_locals_analysis = HaveBeenBorrowedLocals :: new ( body) ;
451
- let borrowed_locals_result =
452
+ let borrowed_locals_results =
452
453
do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, borrowed_locals_analysis,
453
454
|bd, p| DebugFormatted :: new ( & bd. body ( ) . local_decls [ p] ) ) ;
455
+ let mut borrowed_locals_cursor = DataflowResultsCursor :: new ( & borrowed_locals_results, body) ;
454
456
455
457
// Calculate the MIR locals that we actually need to keep storage around
456
458
// 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 =
459
461
do_dataflow ( tcx, body, def_id, & [ ] , & dead_unwinds, requires_storage_analysis,
460
462
|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 ) ;
462
464
463
465
// Calculate the liveness of MIR locals ignoring borrows.
464
466
let mut live_locals = liveness:: LiveVarSet :: new_empty ( body. local_decls . len ( ) ) ;
@@ -484,10 +486,6 @@ fn locals_live_across_suspend_points(
484
486
} ;
485
487
486
488
if !movable {
487
- let borrowed_locals = state_for_location ( loc,
488
- & borrowed_locals_analysis,
489
- & borrowed_locals_result,
490
- body) ;
491
489
// The `liveness` variable contains the liveness of MIR locals ignoring borrows.
492
490
// This is correct for movable generators since borrows cannot live across
493
491
// suspension points. However for immovable generators we need to account for
@@ -498,22 +496,19 @@ fn locals_live_across_suspend_points(
498
496
// If a borrow is converted to a raw reference, we must also assume that it lives
499
497
// forever. Note that the final liveness is still bounded by the storage liveness
500
498
// 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 ( ) ) ;
502
501
}
503
502
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 ( ) ;
508
505
509
506
// Store the storage liveness for later use so we can restore the state
510
507
// after a suspension point
511
508
storage_liveness_map. insert ( block, storage_liveness. clone ( ) ) ;
512
509
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 ( ) ;
517
512
518
513
// Mark locals without storage statements as always requiring storage
519
514
storage_required. union ( & ignored. 0 ) ;
@@ -549,8 +544,7 @@ fn locals_live_across_suspend_points(
549
544
body,
550
545
& live_locals,
551
546
& ignored,
552
- requires_storage,
553
- requires_storage_analysis) ;
547
+ requires_storage_results) ;
554
548
555
549
LivenessInfo {
556
550
live_locals,
@@ -588,7 +582,6 @@ fn compute_storage_conflicts(
588
582
stored_locals : & liveness:: LiveVarSet ,
589
583
ignored : & StorageIgnored ,
590
584
requires_storage : DataflowResults < ' tcx , RequiresStorage < ' mir , ' tcx > > ,
591
- _requires_storage_analysis : RequiresStorage < ' mir , ' tcx > ,
592
585
) -> BitMatrix < GeneratorSavedLocal , GeneratorSavedLocal > {
593
586
assert_eq ! ( body. local_decls. len( ) , ignored. 0 . domain_size( ) ) ;
594
587
assert_eq ! ( body. local_decls. len( ) , stored_locals. domain_size( ) ) ;
0 commit comments