@@ -118,53 +118,57 @@ pub(crate) enum RegionElement {
118
118
119
119
/// Records the CFG locations where each region is live. When we initially compute liveness, we use
120
120
/// an interval matrix storing liveness ranges for each region-vid.
121
- pub ( crate ) struct LivenessValues < N : Idx > {
121
+ pub ( crate ) struct LivenessValues {
122
122
elements : Rc < RegionValueElements > ,
123
- points : SparseIntervalMatrix < N , PointIndex > ,
123
+ points : SparseIntervalMatrix < RegionVid , PointIndex > ,
124
124
}
125
125
126
- impl < N : Idx > LivenessValues < N > {
126
+ impl LivenessValues {
127
127
/// Create an empty map of regions to locations where they're live.
128
128
pub ( crate ) fn new ( elements : Rc < RegionValueElements > ) -> Self {
129
129
Self { points : SparseIntervalMatrix :: new ( elements. num_points ) , elements }
130
130
}
131
131
132
132
/// Iterate through each region that has a value in this set.
133
- pub ( crate ) fn regions ( & self ) -> impl Iterator < Item = N > {
133
+ pub ( crate ) fn regions ( & self ) -> impl Iterator < Item = RegionVid > {
134
134
self . points . rows ( )
135
135
}
136
136
137
137
/// Records `region` as being live at the given `location`.
138
- pub ( crate ) fn add_location ( & mut self , region : N , location : Location ) {
138
+ pub ( crate ) fn add_location ( & mut self , region : RegionVid , location : Location ) {
139
139
debug ! ( "LivenessValues::add_location(region={:?}, location={:?})" , region, location) ;
140
140
let point = self . elements . point_from_location ( location) ;
141
141
self . points . insert ( region, point) ;
142
142
}
143
143
144
144
/// Records `region` as being live at all the given `points`.
145
- pub ( crate ) fn add_points ( & mut self , region : N , points : & IntervalSet < PointIndex > ) -> bool {
145
+ pub ( crate ) fn add_points (
146
+ & mut self ,
147
+ region : RegionVid ,
148
+ points : & IntervalSet < PointIndex > ,
149
+ ) -> bool {
146
150
debug ! ( "LivenessValues::add_points(region={:?}, points={:?})" , region, points) ;
147
151
self . points . union_row ( region, points)
148
152
}
149
153
150
- /// Record `region` as being live at all the control-flow points.
151
- pub ( crate ) fn add_all_points ( & mut self , region : N ) {
154
+ /// Records `region` as being live at all the control-flow points.
155
+ pub ( crate ) fn add_all_points ( & mut self , region : RegionVid ) {
152
156
self . points . insert_all_into_row ( region) ;
153
157
}
154
158
155
159
/// Returns whether `region` is marked live at the given `location`.
156
- pub ( crate ) fn is_live_at ( & self , region : N , location : Location ) -> bool {
160
+ pub ( crate ) fn is_live_at ( & self , region : RegionVid , location : Location ) -> bool {
157
161
let point = self . elements . point_from_location ( location) ;
158
162
self . points . row ( region) . is_some_and ( |r| r. contains ( point) )
159
163
}
160
164
161
165
/// Returns whether `region` is marked live at any location.
162
- pub ( crate ) fn is_live_anywhere ( & self , region : N ) -> bool {
166
+ pub ( crate ) fn is_live_anywhere ( & self , region : RegionVid ) -> bool {
163
167
self . live_points ( region) . next ( ) . is_some ( )
164
168
}
165
169
166
170
/// Returns an iterator of all the points where `region` is live.
167
- fn live_points ( & self , region : N ) -> impl Iterator < Item = PointIndex > + ' _ {
171
+ fn live_points ( & self , region : RegionVid ) -> impl Iterator < Item = PointIndex > + ' _ {
168
172
self . points
169
173
. row ( region)
170
174
. into_iter ( )
@@ -173,7 +177,7 @@ impl<N: Idx> LivenessValues<N> {
173
177
}
174
178
175
179
/// Returns a "pretty" string value of the region. Meant for debugging.
176
- pub ( crate ) fn region_value_str ( & self , region : N ) -> String {
180
+ pub ( crate ) fn region_value_str ( & self , region : RegionVid ) -> String {
177
181
region_value_str (
178
182
self . live_points ( region)
179
183
. map ( move |p| RegionElement :: Location ( self . elements . to_location ( p) ) ) ,
@@ -310,7 +314,7 @@ impl<N: Idx> RegionValues<N> {
310
314
/// `self[to] |= values[from]`, essentially: that is, take all the
311
315
/// elements for the region `from` from `values` and add them to
312
316
/// the region `to` in `self`.
313
- pub ( crate ) fn merge_liveness < M : Idx > ( & mut self , to : N , from : M , values : & LivenessValues < M > ) {
317
+ pub ( crate ) fn merge_liveness ( & mut self , to : N , from : RegionVid , values : & LivenessValues ) {
314
318
if let Some ( set) = values. points . row ( from) {
315
319
self . points . union_row ( to, set) ;
316
320
}
0 commit comments