@@ -16,7 +16,7 @@ use rustc::util::nodemap::FxHashMap;
16
16
use rustc_data_structures:: indexed_vec:: Idx ;
17
17
use std:: collections:: BTreeSet ;
18
18
use std:: fmt;
19
- use util:: liveness:: { self , LivenessResult } ;
19
+ use util:: liveness:: { self , LivenessResult , LivenessMode } ;
20
20
21
21
use util as mir_util;
22
22
use self :: mir_util:: PassWhere ;
@@ -50,7 +50,17 @@ impl MirPass for NLL {
50
50
let num_region_variables = renumber:: renumber_mir ( infcx, mir) ;
51
51
52
52
// Compute what is live where.
53
- let liveness = & liveness:: liveness_of_locals ( mir) ;
53
+ let liveness = & LivenessResults {
54
+ regular : liveness:: liveness_of_locals ( mir, LivenessMode {
55
+ include_regular_use : true ,
56
+ include_drops : false ,
57
+ } ) ,
58
+
59
+ drop : liveness:: liveness_of_locals ( mir, LivenessMode {
60
+ include_regular_use : false ,
61
+ include_drops : true ,
62
+ } )
63
+ } ;
54
64
55
65
// Create the region inference context, generate the constraints,
56
66
// and then solve them.
@@ -64,9 +74,14 @@ impl MirPass for NLL {
64
74
}
65
75
}
66
76
77
+ struct LivenessResults {
78
+ regular : LivenessResult ,
79
+ drop : LivenessResult ,
80
+ }
81
+
67
82
fn dump_mir_results < ' a , ' gcx , ' tcx > (
68
83
infcx : & InferCtxt < ' a , ' gcx , ' tcx > ,
69
- liveness : & LivenessResult ,
84
+ liveness : & LivenessResults ,
70
85
source : MirSource ,
71
86
regioncx : & RegionInferenceContext ,
72
87
mir : & Mir < ' tcx > ,
@@ -75,11 +90,22 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
75
90
return ;
76
91
}
77
92
78
- let liveness_per_location: FxHashMap < _ , _ > = mir. basic_blocks ( )
93
+ let regular_liveness_per_location: FxHashMap < _ , _ > = mir. basic_blocks ( )
94
+ . indices ( )
95
+ . flat_map ( |bb| {
96
+ let mut results = vec ! [ ] ;
97
+ liveness. regular . simulate_block ( & mir, bb, |location, local_set| {
98
+ results. push ( ( location, local_set. clone ( ) ) ) ;
99
+ } ) ;
100
+ results
101
+ } )
102
+ . collect ( ) ;
103
+
104
+ let drop_liveness_per_location: FxHashMap < _ , _ > = mir. basic_blocks ( )
79
105
. indices ( )
80
106
. flat_map ( |bb| {
81
107
let mut results = vec ! [ ] ;
82
- liveness. simulate_block ( & mir, bb, |location, local_set| {
108
+ liveness. drop . simulate_block ( & mir, bb, |location, local_set| {
83
109
results. push ( ( location, local_set. clone ( ) ) ) ;
84
110
} ) ;
85
111
results
@@ -96,16 +122,17 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
96
122
// Before each basic block, dump out the values
97
123
// that are live on entry to the basic block.
98
124
PassWhere :: BeforeBlock ( bb) => {
99
- let local_set = & liveness. ins [ bb] ;
100
- writeln ! ( out, " | Variables live on entry to the block {:?}:" , bb) ?;
101
- for local in local_set. iter ( ) {
102
- writeln ! ( out, " | - {:?}" , local) ?;
103
- }
125
+ writeln ! ( out, " | Variables regular-live on entry to the block {:?}: {:?}" ,
126
+ bb, liveness. regular. ins[ bb] ) ?;
127
+ writeln ! ( out, " | Variables drop-live on entry to the block {:?}: {:?}" ,
128
+ bb, liveness. drop. ins[ bb] ) ?;
104
129
}
105
130
106
131
PassWhere :: InCFG ( location) => {
107
- let local_set = & liveness_per_location[ & location] ;
108
- writeln ! ( out, " | Live variables here: {:?}" , local_set) ?;
132
+ let local_set = & regular_liveness_per_location[ & location] ;
133
+ writeln ! ( out, " | Regular-Live variables here: {:?}" , local_set) ?;
134
+ let local_set = & drop_liveness_per_location[ & location] ;
135
+ writeln ! ( out, " | Drop-Live variables here: {:?}" , local_set) ?;
109
136
}
110
137
111
138
PassWhere :: AfterCFG => { }
0 commit comments