diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-12-05 11:15:59 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-12-05 20:07:25 +1100 |
| commit | 6ee1a7aaa02f7e7713c8b60d785610983dc69ee7 (patch) | |
| tree | c159f95a3fb0745e097dde52bece0d24cf6828be /compiler/rustc_mir_dataflow/src/framework/mod.rs | |
| parent | dff5ce68816edaf8a8740db60a8aa735641939f7 (diff) | |
| download | rust-6ee1a7aaa02f7e7713c8b60d785610983dc69ee7.tar.gz rust-6ee1a7aaa02f7e7713c8b60d785610983dc69ee7.zip | |
Introduce `MixedBitSet`.
It just uses `BitSet` for small/medium sizes (<= 2048 bits) and `ChunkedBitSet` for larger sizes. This is good because `ChunkedBitSet` is slow and memory-hungry at smaller sizes.
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/framework/mod.rs')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/framework/mod.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs index b9407882ec5..40fb22014e5 100644 --- a/compiler/rustc_mir_dataflow/src/framework/mod.rs +++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs @@ -35,7 +35,7 @@ use std::cmp::Ordering; use rustc_data_structures::work_queue::WorkQueue; -use rustc_index::bit_set::{BitSet, ChunkedBitSet}; +use rustc_index::bit_set::{BitSet, ChunkedBitSet, MixedBitSet}; use rustc_index::{Idx, IndexVec}; use rustc_middle::bug; use rustc_middle::mir::{self, BasicBlock, CallReturnPlaces, Location, TerminatorEdges, traversal}; @@ -77,6 +77,12 @@ impl<T: Idx> BitSetExt<T> for ChunkedBitSet<T> { } } +impl<T: Idx> BitSetExt<T> for MixedBitSet<T> { + fn contains(&self, elem: T) -> bool { + self.contains(elem) + } +} + /// A dataflow problem with an arbitrarily complex transfer function. /// /// This trait specifies the lattice on which this analysis operates (the domain), its @@ -337,6 +343,16 @@ impl<T: Idx> GenKill<T> for ChunkedBitSet<T> { } } +impl<T: Idx> GenKill<T> for MixedBitSet<T> { + fn gen_(&mut self, elem: T) { + self.insert(elem); + } + + fn kill(&mut self, elem: T) { + self.remove(elem); + } +} + impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> { fn gen_(&mut self, elem: T) { match self { |
