Skip to content

Commit 5dfe648

Browse files
committed
Auto merge of #134438 - lqd:const-qualif-bitsets, r=compiler-errors
Use `MixedBitSet`s in const qualif These analyses' domains should be very homogeneous, having compressed bitmaps on huge cfgs should make a difference (and doesn’t have an impact on the smaller / regular cfgs in our benchmarks). This is a >40% walltime reduction on [this stress test](https://github.com/Manishearth/icu4x_compile_sample) extracted from a real world ICU case, and a 10x or so max-rss reduction. cc `@oli-obk` `@RalfJung` Should help with (or fix) issue #134404.
2 parents 214587c + db7d6a9 commit 5dfe648

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

compiler/rustc_const_eval/src/check_consts/resolver.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::fmt;
66
use std::marker::PhantomData;
77

8-
use rustc_index::bit_set::BitSet;
8+
use rustc_index::bit_set::MixedBitSet;
99
use rustc_middle::mir::visit::Visitor;
1010
use rustc_middle::mir::{
1111
self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges,
@@ -246,12 +246,14 @@ where
246246
}
247247

248248
#[derive(Debug, PartialEq, Eq)]
249+
/// The state for the `FlowSensitiveAnalysis` dataflow analysis. This domain is likely homogeneous,
250+
/// and has a big size, so we use a bitset that can be sparse (c.f. issue #134404).
249251
pub(super) struct State {
250252
/// Describes whether a local contains qualif.
251-
pub qualif: BitSet<Local>,
253+
pub qualif: MixedBitSet<Local>,
252254
/// Describes whether a local's address escaped and it might become qualified as a result an
253255
/// indirect mutation.
254-
pub borrow: BitSet<Local>,
256+
pub borrow: MixedBitSet<Local>,
255257
}
256258

257259
impl Clone for State {
@@ -320,8 +322,8 @@ where
320322

321323
fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
322324
State {
323-
qualif: BitSet::new_empty(body.local_decls.len()),
324-
borrow: BitSet::new_empty(body.local_decls.len()),
325+
qualif: MixedBitSet::new_empty(body.local_decls.len()),
326+
borrow: MixedBitSet::new_empty(body.local_decls.len()),
325327
}
326328
}
327329

compiler/rustc_index/src/bit_set.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,14 @@ impl<T: Idx> MixedBitSet<T> {
11911191
}
11921192
}
11931193

1194+
#[inline]
1195+
pub fn clear(&mut self) {
1196+
match self {
1197+
MixedBitSet::Small(set) => set.clear(),
1198+
MixedBitSet::Large(set) => set.clear(),
1199+
}
1200+
}
1201+
11941202
bit_relations_inherent_impls! {}
11951203
}
11961204

0 commit comments

Comments
 (0)