Skip to content

Commit 855183d

Browse files
committed
Use DenseBit for drop_live_at in liveness tracing
1 parent a3e94c2 commit 855183d

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

  • compiler/rustc_borrowck/src/type_check/liveness

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct LivenessResults<'a, 'typeck, 'tcx> {
110110
/// Points where the current variable is "drop live" -- meaning
111111
/// that there is no future "full use" that may use its value, but
112112
/// there is a future drop.
113-
drop_live_at: IntervalSet<PointIndex>,
113+
drop_live_at: DenseBitSet<PointIndex>,
114114

115115
/// Locations where drops may occur.
116116
drop_locations: Vec<Location>,
@@ -126,7 +126,7 @@ impl<'a, 'typeck, 'tcx> LivenessResults<'a, 'typeck, 'tcx> {
126126
cx,
127127
defs: DenseBitSet::new_empty(num_points),
128128
use_live_at: IntervalSet::new(num_points),
129-
drop_live_at: IntervalSet::new(num_points),
129+
drop_live_at: DenseBitSet::new_empty(num_points),
130130
drop_locations: vec![],
131131
stack: vec![],
132132
}
@@ -146,12 +146,16 @@ impl<'a, 'typeck, 'tcx> LivenessResults<'a, 'typeck, 'tcx> {
146146
}
147147

148148
if !self.drop_live_at.is_empty() {
149-
self.cx.add_drop_live_facts_for(
150-
local,
151-
local_ty,
152-
&self.drop_locations,
153-
&self.drop_live_at,
154-
);
149+
// `drop_live_at` is using a DenseBitSet, but `add_drop_live_facts_for` expects
150+
// an IntervalSet. We thus convert between those two here.
151+
let mut set: IntervalSet<PointIndex> =
152+
IntervalSet::new(self.drop_live_at.domain_size());
153+
for item in self.drop_live_at {
154+
// We iterate the `drop_live_at` set from smallest to largest values, so
155+
// we can use append to add things to the interval set at the end.
156+
set.append(item);
157+
}
158+
self.cx.add_drop_live_facts_for(local, local_ty, &self.drop_locations, &set);
155159
}
156160
}
157161
}

0 commit comments

Comments
 (0)