@@ -37,7 +37,7 @@ use rustc::mir::visit::MirVisitable;
3737use rustc:: mir:: visit:: { PlaceContext , Visitor } ;
3838use rustc:: mir:: Local ;
3939use rustc:: mir:: * ;
40- use rustc:: ty:: { item_path, TyCtxt , TypeFoldable } ;
40+ use rustc:: ty:: { item_path, TyCtxt } ;
4141use rustc_data_structures:: indexed_set:: IdxSetBuf ;
4242use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
4343use rustc_data_structures:: work_queue:: WorkQueue ;
@@ -47,7 +47,7 @@ use std::path::{Path, PathBuf};
4747use transform:: MirSource ;
4848use util:: pretty:: { dump_enabled, write_basic_block, write_mir_intro} ;
4949
50- pub type LocalSet < V > = IdxSetBuf < V > ;
50+ pub type LiveVarSet < V > = IdxSetBuf < V > ;
5151
5252/// This gives the result of the liveness analysis at the boundary of
5353/// basic blocks. You can use `simulate_block` to obtain the
@@ -63,7 +63,7 @@ pub struct LivenessResult<V: Idx> {
6363
6464 /// Live variables on exit to each basic block. This is equal to
6565 /// the union of the `ins` for each successor.
66- pub outs : IndexVec < BasicBlock , LocalSet < V > > ,
66+ pub outs : IndexVec < BasicBlock , LiveVarSet < V > > ,
6767}
6868
6969/// Defines the mapping to/from the MIR local variables (`Local`) to
@@ -176,13 +176,13 @@ pub fn liveness_of_locals<'tcx, V: Idx>(
176176 . map ( |b| block ( mode, map, b, num_live_vars) )
177177 . collect ( ) ;
178178
179- let mut outs: IndexVec < _ , LocalSet < V > > = mir
179+ let mut outs: IndexVec < _ , LiveVarSet < V > > = mir
180180 . basic_blocks ( )
181181 . indices ( )
182- . map ( |_| LocalSet :: new_empty ( num_live_vars) )
182+ . map ( |_| LiveVarSet :: new_empty ( num_live_vars) )
183183 . collect ( ) ;
184184
185- let mut bits = LocalSet :: new_empty ( num_live_vars) ;
185+ let mut bits = LiveVarSet :: new_empty ( num_live_vars) ;
186186
187187 // queue of things that need to be re-processed, and a set containing
188188 // the things currently in the queue
@@ -223,7 +223,7 @@ impl<V: Idx> LivenessResult<V> {
223223 map : & impl LiveVariableMap < LiveVar = V > ,
224224 mut callback : OP ,
225225 ) where
226- OP : FnMut ( Location , & LocalSet < V > ) ,
226+ OP : FnMut ( Location , & LiveVarSet < V > ) ,
227227 {
228228 let data = & mir[ block] ;
229229
@@ -244,8 +244,8 @@ impl<V: Idx> LivenessResult<V> {
244244 mode : self . mode ,
245245 map,
246246 defs_uses : DefsUses {
247- defs : LocalSet :: new_empty ( num_live_vars) ,
248- uses : LocalSet :: new_empty ( num_live_vars) ,
247+ defs : LiveVarSet :: new_empty ( num_live_vars) ,
248+ uses : LiveVarSet :: new_empty ( num_live_vars) ,
249249 } ,
250250 } ;
251251 // Visit the various parts of the basic block in reverse. If we go
@@ -362,8 +362,8 @@ where
362362
363363#[ derive( Eq , PartialEq , Clone ) ]
364364struct DefsUses < V : Idx > {
365- defs : LocalSet < V > ,
366- uses : LocalSet < V > ,
365+ defs : LiveVarSet < V > ,
366+ uses : LiveVarSet < V > ,
367367}
368368
369369impl < V : Idx > DefsUses < V > {
@@ -372,7 +372,7 @@ impl<V: Idx> DefsUses<V> {
372372 self . defs . clear ( ) ;
373373 }
374374
375- fn apply ( & self , bits : & mut LocalSet < V > ) -> bool {
375+ fn apply ( & self , bits : & mut LiveVarSet < V > ) -> bool {
376376 bits. subtract ( & self . defs ) | bits. union ( & self . uses )
377377 }
378378
@@ -418,10 +418,10 @@ where
418418 & mut self ,
419419 location : Location ,
420420 value : & impl MirVisitable < ' tcx > ,
421- bits : & mut LocalSet < V > ,
421+ bits : & mut LiveVarSet < V > ,
422422 callback : & mut OP ,
423423 ) where
424- OP : FnMut ( Location , & LocalSet < V > ) ,
424+ OP : FnMut ( Location , & LiveVarSet < V > ) ,
425425 {
426426 value. apply ( location, self ) ;
427427 self . defs_uses . apply ( bits) ;
@@ -455,8 +455,8 @@ fn block<'tcx, V: Idx>(
455455 mode,
456456 map,
457457 defs_uses : DefsUses {
458- defs : LocalSet :: new_empty ( locals) ,
459- uses : LocalSet :: new_empty ( locals) ,
458+ defs : LiveVarSet :: new_empty ( locals) ,
459+ uses : LiveVarSet :: new_empty ( locals) ,
460460 } ,
461461 } ;
462462
@@ -527,7 +527,7 @@ pub fn write_mir_fn<'a, 'tcx, V: Idx>(
527527) -> io:: Result < ( ) > {
528528 write_mir_intro ( tcx, src, mir, w) ?;
529529 for block in mir. basic_blocks ( ) . indices ( ) {
530- let print = |w : & mut dyn Write , prefix, result : & IndexVec < BasicBlock , LocalSet < V > > | {
530+ let print = |w : & mut dyn Write , prefix, result : & IndexVec < BasicBlock , LiveVarSet < V > > | {
531531 let live: Vec < String > = result[ block] . iter ( )
532532 . map ( |v| map. from_live_var ( v) )
533533 . map ( |local| format ! ( "{:?}" , local) )
@@ -545,43 +545,4 @@ pub fn write_mir_fn<'a, 'tcx, V: Idx>(
545545 Ok ( ( ) )
546546}
547547
548- crate struct NllLivenessMap {
549- pub from_local : IndexVec < Local , Option < LocalWithRegion > > ,
550- pub to_local : IndexVec < LocalWithRegion , Local > ,
551548
552- }
553-
554- impl LiveVariableMap for NllLivenessMap {
555- type LiveVar = LocalWithRegion ;
556-
557- fn from_local ( & self , local : Local ) -> Option < Self :: LiveVar > {
558- self . from_local [ local]
559- }
560-
561- fn from_live_var ( & self , local : Self :: LiveVar ) -> Local {
562- self . to_local [ local]
563- }
564-
565- fn num_variables ( & self ) -> usize {
566- self . to_local . len ( )
567- }
568- }
569-
570- impl NllLivenessMap {
571- pub fn compute ( mir : & Mir ) -> Self {
572- let mut to_local = IndexVec :: default ( ) ;
573- let from_local: IndexVec < Local , Option < _ > > = mir
574- . local_decls
575- . iter_enumerated ( )
576- . map ( |( local, local_decl) | {
577- if local_decl. ty . has_free_regions ( ) {
578- Some ( to_local. push ( local) )
579- }
580- else {
581- None
582- }
583- } ) . collect ( ) ;
584-
585- Self { from_local, to_local }
586- }
587- }
0 commit comments