@@ -76,7 +76,7 @@ pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> {
76
76
/// The locals are stored as `Option<Value>`s.
77
77
/// `None` represents a local that is currently dead, while a live local
78
78
/// can either directly contain `Scalar` or refer to some part of an `Allocation`.
79
- pub locals : IndexVec < mir:: Local , LocalValue < ' tcx , Tag > > ,
79
+ pub locals : IndexVec < mir:: Local , LocalState < ' tcx , Tag > > ,
80
80
81
81
////////////////////////////////////////////////////////////////////////////////
82
82
// Current position within the function
@@ -107,15 +107,15 @@ pub enum StackPopCleanup {
107
107
108
108
/// State of a local variable including a memoized layout
109
109
#[ derive( Clone , PartialEq , Eq ) ]
110
- pub struct LocalValue < ' tcx , Tag =( ) , Id =AllocId > {
111
- pub state : LocalState < Tag , Id > ,
110
+ pub struct LocalState < ' tcx , Tag =( ) , Id =AllocId > {
111
+ pub state : LocalValue < Tag , Id > ,
112
112
/// Don't modify if `Some`, this is only used to prevent computing the layout twice
113
113
pub layout : Cell < Option < TyLayout < ' tcx > > > ,
114
114
}
115
115
116
116
/// State of a local variable
117
117
#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
118
- pub enum LocalState < Tag =( ) , Id =AllocId > {
118
+ pub enum LocalValue < Tag =( ) , Id =AllocId > {
119
119
Dead ,
120
120
// Mostly for convenience, we re-use the `Operand` type here.
121
121
// This is an optimization over just always having a pointer here;
@@ -124,18 +124,18 @@ pub enum LocalState<Tag=(), Id=AllocId> {
124
124
Live ( Operand < Tag , Id > ) ,
125
125
}
126
126
127
- impl < ' tcx , Tag > LocalValue < ' tcx , Tag > {
127
+ impl < ' tcx , Tag > LocalState < ' tcx , Tag > {
128
128
pub fn access ( & self ) -> EvalResult < ' tcx , & Operand < Tag > > {
129
129
match self . state {
130
- LocalState :: Dead => err ! ( DeadLocal ) ,
131
- LocalState :: Live ( ref val) => Ok ( val) ,
130
+ LocalValue :: Dead => err ! ( DeadLocal ) ,
131
+ LocalValue :: Live ( ref val) => Ok ( val) ,
132
132
}
133
133
}
134
134
135
135
pub fn access_mut ( & mut self ) -> EvalResult < ' tcx , & mut Operand < Tag > > {
136
136
match self . state {
137
- LocalState :: Dead => err ! ( DeadLocal ) ,
138
- LocalState :: Live ( ref mut val) => Ok ( val) ,
137
+ LocalValue :: Dead => err ! ( DeadLocal ) ,
138
+ LocalValue :: Live ( ref mut val) => Ok ( val) ,
139
139
}
140
140
}
141
141
}
@@ -474,18 +474,18 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
474
474
// don't allocate at all for trivial constants
475
475
if mir. local_decls . len ( ) > 1 {
476
476
// We put some marker immediate into the locals that we later want to initialize.
477
- // This can be anything except for LocalState ::Dead -- because *that* is the
477
+ // This can be anything except for LocalValue ::Dead -- because *that* is the
478
478
// value we use for things that we know are initially dead.
479
- let dummy = LocalValue {
480
- state : LocalState :: Live ( Operand :: Immediate ( Immediate :: Scalar (
479
+ let dummy = LocalState {
480
+ state : LocalValue :: Live ( Operand :: Immediate ( Immediate :: Scalar (
481
481
ScalarMaybeUndef :: Undef ,
482
482
) ) ) ,
483
483
layout : Cell :: new ( None ) ,
484
484
} ;
485
485
let mut locals = IndexVec :: from_elem ( dummy, & mir. local_decls ) ;
486
486
// Return place is handled specially by the `eval_place` functions, and the
487
487
// entry in `locals` should never be used. Make it dead, to be sure.
488
- locals[ mir:: RETURN_PLACE ] . state = LocalState :: Dead ;
488
+ locals[ mir:: RETURN_PLACE ] . state = LocalValue :: Dead ;
489
489
// Now mark those locals as dead that we do not want to initialize
490
490
match self . tcx . describe_def ( instance. def_id ( ) ) {
491
491
// statics and constants don't have `Storage*` statements, no need to look for them
@@ -498,7 +498,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
498
498
match stmt. kind {
499
499
StorageLive ( local) |
500
500
StorageDead ( local) => {
501
- locals[ local] . state = LocalState :: Dead ;
501
+ locals[ local] . state = LocalValue :: Dead ;
502
502
}
503
503
_ => { }
504
504
}
@@ -509,14 +509,14 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
509
509
// Finally, properly initialize all those that still have the dummy value
510
510
for ( idx, local) in locals. iter_enumerated_mut ( ) {
511
511
match local. state {
512
- LocalState :: Live ( _) => {
512
+ LocalValue :: Live ( _) => {
513
513
// This needs to be properly initialized.
514
514
let ty = self . monomorphize ( mir. local_decls [ idx] . ty ) ?;
515
515
let layout = self . layout_of ( ty) ?;
516
- local. state = LocalState :: Live ( self . uninit_operand ( layout) ?) ;
516
+ local. state = LocalValue :: Live ( self . uninit_operand ( layout) ?) ;
517
517
local. layout = Cell :: new ( Some ( layout) ) ;
518
518
}
519
- LocalState :: Dead => {
519
+ LocalValue :: Dead => {
520
520
// Nothing to do
521
521
}
522
522
}
@@ -603,31 +603,31 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
603
603
pub fn storage_live (
604
604
& mut self ,
605
605
local : mir:: Local
606
- ) -> EvalResult < ' tcx , LocalState < M :: PointerTag > > {
606
+ ) -> EvalResult < ' tcx , LocalValue < M :: PointerTag > > {
607
607
assert ! ( local != mir:: RETURN_PLACE , "Cannot make return place live" ) ;
608
608
trace ! ( "{:?} is now live" , local) ;
609
609
610
610
let layout = self . layout_of_local ( self . frame ( ) , local, None ) ?;
611
- let init = LocalState :: Live ( self . uninit_operand ( layout) ?) ;
611
+ let init = LocalValue :: Live ( self . uninit_operand ( layout) ?) ;
612
612
// StorageLive *always* kills the value that's currently stored
613
613
Ok ( mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , init) )
614
614
}
615
615
616
616
/// Returns the old value of the local.
617
617
/// Remember to deallocate that!
618
- pub fn storage_dead ( & mut self , local : mir:: Local ) -> LocalState < M :: PointerTag > {
618
+ pub fn storage_dead ( & mut self , local : mir:: Local ) -> LocalValue < M :: PointerTag > {
619
619
assert ! ( local != mir:: RETURN_PLACE , "Cannot make return place dead" ) ;
620
620
trace ! ( "{:?} is now dead" , local) ;
621
621
622
- mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , LocalState :: Dead )
622
+ mem:: replace ( & mut self . frame_mut ( ) . locals [ local] . state , LocalValue :: Dead )
623
623
}
624
624
625
625
pub ( super ) fn deallocate_local (
626
626
& mut self ,
627
- local : LocalState < M :: PointerTag > ,
627
+ local : LocalValue < M :: PointerTag > ,
628
628
) -> EvalResult < ' tcx > {
629
629
// FIXME: should we tell the user that there was a local which was never written to?
630
- if let LocalState :: Live ( Operand :: Indirect ( MemPlace { ptr, .. } ) ) = local {
630
+ if let LocalValue :: Live ( Operand :: Indirect ( MemPlace { ptr, .. } ) ) = local {
631
631
trace ! ( "deallocating local" ) ;
632
632
let ptr = ptr. to_ptr ( ) ?;
633
633
self . memory . dump_alloc ( ptr. alloc_id ) ;
0 commit comments