@@ -2,12 +2,21 @@ pub use super::*;
22
33use crate :: dataflow:: BottomValue ;
44use crate :: dataflow:: { self , GenKill , Results , ResultsRefCursor } ;
5+ use crate :: util:: storage:: AlwaysLiveLocals ;
56use rustc_middle:: mir:: visit:: { NonMutatingUseContext , PlaceContext , Visitor } ;
67use rustc_middle:: mir:: * ;
78use std:: cell:: RefCell ;
89
9- #[ derive( Copy , Clone ) ]
10- pub struct MaybeStorageLive ;
10+ #[ derive( Clone ) ]
11+ pub struct MaybeStorageLive {
12+ always_live_locals : AlwaysLiveLocals ,
13+ }
14+
15+ impl MaybeStorageLive {
16+ pub fn new ( always_live_locals : AlwaysLiveLocals ) -> Self {
17+ MaybeStorageLive { always_live_locals }
18+ }
19+ }
1120
1221impl dataflow:: AnalysisDomain < ' tcx > for MaybeStorageLive {
1322 type Idx = Local ;
@@ -19,9 +28,12 @@ impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
1928 }
2029
2130 fn initialize_start_block ( & self , body : & mir:: Body < ' tcx > , on_entry : & mut BitSet < Self :: Idx > ) {
22- // The resume argument is live on function entry (we don't care about
23- // the `self` argument)
24- for arg in body. args_iter ( ) . skip ( 1 ) {
31+ assert_eq ! ( body. local_decls. len( ) , self . always_live_locals. domain_size( ) ) ;
32+ for local in self . always_live_locals . iter ( ) {
33+ on_entry. insert ( local) ;
34+ }
35+
36+ for arg in body. args_iter ( ) {
2537 on_entry. insert ( arg) ;
2638 }
2739 }
0 commit comments