1
1
use std:: sync:: OnceLock ;
2
2
3
- use rustc_data_structures:: fx:: FxHashMap ;
4
3
use rustc_data_structures:: graph;
5
4
use rustc_data_structures:: graph:: dominators:: { Dominators , dominators} ;
6
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
@@ -10,7 +9,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
10
9
use smallvec:: SmallVec ;
11
10
12
11
use crate :: mir:: traversal:: Postorder ;
13
- use crate :: mir:: { BasicBlock , BasicBlockData , START_BLOCK , Terminator , TerminatorKind } ;
12
+ use crate :: mir:: { BasicBlock , BasicBlockData , START_BLOCK } ;
14
13
15
14
#[ derive( Clone , TyEncodable , TyDecodable , Debug , HashStable , TypeFoldable , TypeVisitable ) ]
16
15
pub struct BasicBlocks < ' tcx > {
@@ -21,15 +20,6 @@ pub struct BasicBlocks<'tcx> {
21
20
// Typically 95%+ of basic blocks have 4 or fewer predecessors.
22
21
type Predecessors = IndexVec < BasicBlock , SmallVec < [ BasicBlock ; 4 ] > > ;
23
22
24
- /// Each `(target, switch)` entry in the map contains a list of switch values
25
- /// that lead to a `target` block from a `switch` block.
26
- ///
27
- /// Note: this type is currently never instantiated, because it's only used for
28
- /// `BasicBlocks::switch_sources`, which is only called by backwards analyses
29
- /// that do `SwitchInt` handling, and we don't have any of those, not even in
30
- /// tests. See #95120 and #94576.
31
- type SwitchSources = FxHashMap < ( BasicBlock , BasicBlock ) , SmallVec < [ SwitchTargetValue ; 1 ] > > ;
32
-
33
23
#[ derive( Debug , Clone , Copy ) ]
34
24
pub enum SwitchTargetValue {
35
25
// A normal switch value.
@@ -41,7 +31,6 @@ pub enum SwitchTargetValue {
41
31
#[ derive( Clone , Default , Debug ) ]
42
32
struct Cache {
43
33
predecessors : OnceLock < Predecessors > ,
44
- switch_sources : OnceLock < SwitchSources > ,
45
34
reverse_postorder : OnceLock < Vec < BasicBlock > > ,
46
35
dominators : OnceLock < Dominators < BasicBlock > > ,
47
36
}
@@ -86,33 +75,6 @@ impl<'tcx> BasicBlocks<'tcx> {
86
75
} )
87
76
}
88
77
89
- /// Returns info about switch values that lead from one block to another
90
- /// block. See `SwitchSources`.
91
- #[ inline]
92
- pub fn switch_sources ( & self ) -> & SwitchSources {
93
- self . cache . switch_sources . get_or_init ( || {
94
- let mut switch_sources: SwitchSources = FxHashMap :: default ( ) ;
95
- for ( bb, data) in self . basic_blocks . iter_enumerated ( ) {
96
- if let Some ( Terminator {
97
- kind : TerminatorKind :: SwitchInt { targets, .. } , ..
98
- } ) = & data. terminator
99
- {
100
- for ( value, target) in targets. iter ( ) {
101
- switch_sources
102
- . entry ( ( target, bb) )
103
- . or_default ( )
104
- . push ( SwitchTargetValue :: Normal ( value) ) ;
105
- }
106
- switch_sources
107
- . entry ( ( targets. otherwise ( ) , bb) )
108
- . or_default ( )
109
- . push ( SwitchTargetValue :: Otherwise ) ;
110
- }
111
- }
112
- switch_sources
113
- } )
114
- }
115
-
116
78
/// Returns mutable reference to basic blocks. Invalidates CFG cache.
117
79
#[ inline]
118
80
pub fn as_mut ( & mut self ) -> & mut IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
0 commit comments