@@ -2,12 +2,21 @@ pub use super::*;
2
2
3
3
use crate :: dataflow:: BottomValue ;
4
4
use crate :: dataflow:: { self , GenKill , Results , ResultsRefCursor } ;
5
+ use crate :: util:: storage:: AlwaysLiveLocals ;
5
6
use rustc_middle:: mir:: visit:: { NonMutatingUseContext , PlaceContext , Visitor } ;
6
7
use rustc_middle:: mir:: * ;
7
8
use std:: cell:: RefCell ;
8
9
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
+ }
11
20
12
21
impl dataflow:: AnalysisDomain < ' tcx > for MaybeStorageLive {
13
22
type Idx = Local ;
@@ -19,9 +28,12 @@ impl dataflow::AnalysisDomain<'tcx> for MaybeStorageLive {
19
28
}
20
29
21
30
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 ( ) {
25
37
on_entry. insert ( arg) ;
26
38
}
27
39
}
0 commit comments