@@ -11,6 +11,7 @@ use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
11
11
use tracing:: debug;
12
12
13
13
use crate :: BorrowIndex ;
14
+ use crate :: polonius:: LiveLoans ;
14
15
15
16
rustc_index:: newtype_index! {
16
17
/// A single integer representing a `ty::Placeholder`.
@@ -50,29 +51,8 @@ pub(crate) struct LivenessValues {
50
51
/// region is live, only that it is.
51
52
points : Option < SparseIntervalMatrix < RegionVid , PointIndex > > ,
52
53
53
- /// When using `-Zpolonius=next`, for each point: the loans flowing into the live regions at
54
- /// that point.
55
- pub ( crate ) loans : Option < LiveLoans > ,
56
- }
57
-
58
- /// Data used to compute the loans that are live at a given point in the CFG, when using
59
- /// `-Zpolonius=next`.
60
- pub ( crate ) struct LiveLoans {
61
- /// The set of loans that flow into a given region. When individual regions are marked as live
62
- /// in the CFG, these inflowing loans are recorded as live.
63
- pub ( crate ) inflowing_loans : SparseBitMatrix < RegionVid , BorrowIndex > ,
64
-
65
- /// The set of loans that are live at a given point in the CFG.
66
- pub ( crate ) live_loans : SparseBitMatrix < PointIndex , BorrowIndex > ,
67
- }
68
-
69
- impl LiveLoans {
70
- pub ( crate ) fn new ( num_loans : usize ) -> Self {
71
- LiveLoans {
72
- live_loans : SparseBitMatrix :: new ( num_loans) ,
73
- inflowing_loans : SparseBitMatrix :: new ( num_loans) ,
74
- }
75
- }
54
+ /// When using `-Zpolonius=next`, the set of loans that are live at a given point in the CFG.
55
+ live_loans : Option < LiveLoans > ,
76
56
}
77
57
78
58
impl LivenessValues {
@@ -82,7 +62,7 @@ impl LivenessValues {
82
62
live_regions : None ,
83
63
points : Some ( SparseIntervalMatrix :: new ( location_map. num_points ( ) ) ) ,
84
64
location_map,
85
- loans : None ,
65
+ live_loans : None ,
86
66
}
87
67
}
88
68
@@ -95,7 +75,7 @@ impl LivenessValues {
95
75
live_regions : Some ( Default :: default ( ) ) ,
96
76
points : None ,
97
77
location_map,
98
- loans : None ,
78
+ live_loans : None ,
99
79
}
100
80
}
101
81
@@ -129,13 +109,6 @@ impl LivenessValues {
129
109
} else if self . location_map . point_in_range ( point) {
130
110
self . live_regions . as_mut ( ) . unwrap ( ) . insert ( region) ;
131
111
}
132
-
133
- // When available, record the loans flowing into this region as live at the given point.
134
- if let Some ( loans) = self . loans . as_mut ( ) {
135
- if let Some ( inflowing) = loans. inflowing_loans . row ( region) {
136
- loans. live_loans . union_row ( point, inflowing) ;
137
- }
138
- }
139
112
}
140
113
141
114
/// Records `region` as being live at all the given `points`.
@@ -146,17 +119,6 @@ impl LivenessValues {
146
119
} else if points. iter ( ) . any ( |point| self . location_map . point_in_range ( point) ) {
147
120
self . live_regions . as_mut ( ) . unwrap ( ) . insert ( region) ;
148
121
}
149
-
150
- // When available, record the loans flowing into this region as live at the given points.
151
- if let Some ( loans) = self . loans . as_mut ( ) {
152
- if let Some ( inflowing) = loans. inflowing_loans . row ( region) {
153
- if !inflowing. is_empty ( ) {
154
- for point in points. iter ( ) {
155
- loans. live_loans . union_row ( point, inflowing) ;
156
- }
157
- }
158
- }
159
- }
160
122
}
161
123
162
124
/// Records `region` as being live at all the control-flow points.
@@ -213,12 +175,17 @@ impl LivenessValues {
213
175
self . location_map . to_location ( point)
214
176
}
215
177
178
+ /// When using `-Zpolonius=next`, records the given live loans for the loan scopes and active
179
+ /// loans dataflow computations.
180
+ pub ( crate ) fn record_live_loans ( & mut self , live_loans : LiveLoans ) {
181
+ self . live_loans = Some ( live_loans) ;
182
+ }
183
+
216
184
/// When using `-Zpolonius=next`, returns whether the `loan_idx` is live at the given `point`.
217
185
pub ( crate ) fn is_loan_live_at ( & self , loan_idx : BorrowIndex , point : PointIndex ) -> bool {
218
- self . loans
186
+ self . live_loans
219
187
. as_ref ( )
220
188
. expect ( "Accessing live loans requires `-Zpolonius=next`" )
221
- . live_loans
222
189
. contains ( point, loan_idx)
223
190
}
224
191
}
0 commit comments