1
+ //! Lazily compute the reverse control-flow graph for the MIR.
2
+
1
3
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
2
4
use rustc_data_structures:: sync:: { Lock , Lrc } ;
3
5
use rustc_index:: vec:: IndexVec ;
@@ -10,13 +12,13 @@ use crate::mir::{BasicBlock, BasicBlockData};
10
12
pub type Predecessors = IndexVec < BasicBlock , SmallVec < [ BasicBlock ; 4 ] > > ;
11
13
12
14
#[ derive( Clone , Debug ) ]
13
- pub struct PredecessorCache {
15
+ pub ( super ) struct PredecessorCache {
14
16
cache : Lock < Option < Lrc < Predecessors > > > ,
15
17
}
16
18
17
19
impl PredecessorCache {
18
20
#[ inline]
19
- pub fn new ( ) -> Self {
21
+ pub ( super ) fn new ( ) -> Self {
20
22
PredecessorCache { cache : Lock :: new ( None ) }
21
23
}
22
24
@@ -27,7 +29,7 @@ impl PredecessorCache {
27
29
/// callers of `invalidate` have a unique reference to the MIR and thus to the predecessor
28
30
/// cache. This means we don't actually need to take a lock when `invalidate` is called.
29
31
#[ inline]
30
- pub fn invalidate ( & mut self ) {
32
+ pub ( super ) fn invalidate ( & mut self ) {
31
33
* self . cache . get_mut ( ) = None ;
32
34
}
33
35
@@ -37,7 +39,7 @@ impl PredecessorCache {
37
39
/// `cache` is only held inside this function. As long as no other locks are taken while
38
40
/// computing the predecessor graph, deadlock is impossible.
39
41
#[ inline]
40
- pub fn compute (
42
+ pub ( super ) fn compute (
41
43
& self ,
42
44
basic_blocks : & IndexVec < BasicBlock , BasicBlockData < ' _ > > ,
43
45
) -> Lrc < Predecessors > {
0 commit comments