11use std:: sync:: OnceLock ;
22
3- use rustc_data_structures:: fx:: FxHashMap ;
43use rustc_data_structures:: graph;
54use rustc_data_structures:: graph:: dominators:: { Dominators , dominators} ;
65use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
@@ -10,7 +9,7 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
109use smallvec:: SmallVec ;
1110
1211use crate :: mir:: traversal:: Postorder ;
13- use crate :: mir:: { BasicBlock , BasicBlockData , START_BLOCK , Terminator , TerminatorKind } ;
12+ use crate :: mir:: { BasicBlock , BasicBlockData , START_BLOCK } ;
1413
1514#[ derive( Clone , TyEncodable , TyDecodable , Debug , HashStable , TypeFoldable , TypeVisitable ) ]
1615pub struct BasicBlocks < ' tcx > {
@@ -21,15 +20,6 @@ pub struct BasicBlocks<'tcx> {
2120// Typically 95%+ of basic blocks have 4 or fewer predecessors.
2221type Predecessors = IndexVec < BasicBlock , SmallVec < [ BasicBlock ; 4 ] > > ;
2322
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-
3323#[ derive( Debug , Clone , Copy ) ]
3424pub enum SwitchTargetValue {
3525 // A normal switch value.
@@ -41,7 +31,6 @@ pub enum SwitchTargetValue {
4131#[ derive( Clone , Default , Debug ) ]
4232struct Cache {
4333 predecessors : OnceLock < Predecessors > ,
44- switch_sources : OnceLock < SwitchSources > ,
4534 reverse_postorder : OnceLock < Vec < BasicBlock > > ,
4635 dominators : OnceLock < Dominators < BasicBlock > > ,
4736}
@@ -86,33 +75,6 @@ impl<'tcx> BasicBlocks<'tcx> {
8675 } )
8776 }
8877
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-
11678 /// Returns mutable reference to basic blocks. Invalidates CFG cache.
11779 #[ inline]
11880 pub fn as_mut ( & mut self ) -> & mut IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
0 commit comments