1
Fork 0

Auto merge of #115422 - Zoxc:cache-once-lock, r=cjgillot

Use `OnceLock` for `SingleCache`

This uses `OnceLock` for `SingleCache` instead of `Lock<Option<T>>` so lookups are lock-free.

r? `@cjgillot`
This commit is contained in:
bors 2023-09-02 03:06:11 +00:00
commit 9dc11a13fa
6 changed files with 21 additions and 21 deletions

View file

@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::graph;
use rustc_data_structures::graph::dominators::{dominators, Dominators};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_data_structures::sync::OnceLock;
use rustc_index::{IndexSlice, IndexVec};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use smallvec::SmallVec;
@ -23,11 +23,11 @@ pub type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u1
#[derive(Clone, Default, Debug)]
struct Cache {
predecessors: OnceCell<Predecessors>,
switch_sources: OnceCell<SwitchSources>,
is_cyclic: OnceCell<bool>,
reverse_postorder: OnceCell<Vec<BasicBlock>>,
dominators: OnceCell<Dominators<BasicBlock>>,
predecessors: OnceLock<Predecessors>,
switch_sources: OnceLock<SwitchSources>,
is_cyclic: OnceLock<bool>,
reverse_postorder: OnceLock<Vec<BasicBlock>>,
dominators: OnceLock<Dominators<BasicBlock>>,
}
impl<'tcx> BasicBlocks<'tcx> {