@@ -11,6 +11,7 @@ use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
1111use tracing:: debug;
1212
1313use crate :: BorrowIndex ;
14+ use crate :: polonius:: LiveLoans ;
1415
1516rustc_index:: newtype_index! {
1617 /// A single integer representing a `ty::Placeholder`.
@@ -50,29 +51,8 @@ pub(crate) struct LivenessValues {
5051 /// region is live, only that it is.
5152 points : Option < SparseIntervalMatrix < RegionVid , PointIndex > > ,
5253
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 > ,
7656}
7757
7858impl LivenessValues {
@@ -82,7 +62,7 @@ impl LivenessValues {
8262 live_regions : None ,
8363 points : Some ( SparseIntervalMatrix :: new ( elements. num_points ( ) ) ) ,
8464 elements,
85- loans : None ,
65+ live_loans : None ,
8666 }
8767 }
8868
@@ -95,7 +75,7 @@ impl LivenessValues {
9575 live_regions : Some ( Default :: default ( ) ) ,
9676 points : None ,
9777 elements,
98- loans : None ,
78+ live_loans : None ,
9979 }
10080 }
10181
@@ -129,13 +109,6 @@ impl LivenessValues {
129109 } else if self . elements . point_in_range ( point) {
130110 self . live_regions . as_mut ( ) . unwrap ( ) . insert ( region) ;
131111 }
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- }
139112 }
140113
141114 /// Records `region` as being live at all the given `points`.
@@ -146,17 +119,6 @@ impl LivenessValues {
146119 } else if points. iter ( ) . any ( |point| self . elements . point_in_range ( point) ) {
147120 self . live_regions . as_mut ( ) . unwrap ( ) . insert ( region) ;
148121 }
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- }
160122 }
161123
162124 /// Records `region` as being live at all the control-flow points.
@@ -212,12 +174,17 @@ impl LivenessValues {
212174 self . elements . to_location ( point)
213175 }
214176
177+ /// When using `-Zpolonius=next`, records the given live loans for the loan scopes and active
178+ /// loans dataflow computations.
179+ pub ( crate ) fn record_live_loans ( & mut self , live_loans : LiveLoans ) {
180+ self . live_loans = Some ( live_loans) ;
181+ }
182+
215183 /// When using `-Zpolonius=next`, returns whether the `loan_idx` is live at the given `point`.
216184 pub ( crate ) fn is_loan_live_at ( & self , loan_idx : BorrowIndex , point : PointIndex ) -> bool {
217- self . loans
185+ self . live_loans
218186 . as_ref ( )
219187 . expect ( "Accessing live loans requires `-Zpolonius=next`" )
220- . live_loans
221188 . contains ( point, loan_idx)
222189 }
223190}
0 commit comments