@@ -4,12 +4,8 @@ use crate::util::spanview::{self, SpanViewable};
44
55use rustc_data_structures:: fingerprint:: Fingerprint ;
66use rustc_data_structures:: graph:: dominators:: { self , Dominators } ;
7- // TODO(richkadel): remove?
8- //use rustc_data_structures::graph::{self, GraphSuccessors, WithSuccessors};
97use rustc_data_structures:: graph:: { self , GraphSuccessors } ;
108use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
11- // TODO(richkadel): remove?
12- //use rustc_data_structures::sync::{Lrc, OnceCell};
139use rustc_data_structures:: sync:: Lrc ;
1410use rustc_index:: bit_set:: BitSet ;
1511use rustc_index:: vec:: IndexVec ;
@@ -29,7 +25,6 @@ use rustc_span::def_id::DefId;
2925use rustc_span:: source_map:: original_sp;
3026use rustc_span:: { BytePos , CharPos , Pos , SourceFile , Span , Symbol , SyntaxContext } ;
3127
32- // TODO(richkadel): remove?
3328use smallvec:: SmallVec ;
3429
3530use std:: cmp:: Ordering ;
@@ -198,40 +193,21 @@ impl BasicCoverageBlockData {
198193 }
199194}
200195
201- // TODO(richkadel): Remove?
202- // impl std::ops::Deref for BasicCoverageBlockData {
203- // type Target = [BasicBlock];
204-
205- // fn deref(&self) -> &[BasicBlock] {
206- // self.basic_blocks.deref()
207- // }
208- // }
209-
210196rustc_index:: newtype_index! {
211197 /// A node in the [control-flow graph][CFG] of BasicCoverageBlocks.
212198 pub struct BasicCoverageBlock {
213- // TODO(richkadel): remove if not needed
214- // derive [HashStable]
215199 DEBUG_FORMAT = "bcb{}" ,
216- // TODO(richkadel): remove if not needed
217- // const START_BLOCK = 0,
218200 }
219201}
220202
221203struct BasicCoverageBlocks {
222- // TODO(richkadel): remove if not needed
223- // struct BasicCoverageBlocks<'a, 'tcx> {
224- // mir_body: &'a mut mir::Body<'tcx>,
225204 bcbs : IndexVec < BasicCoverageBlock , BasicCoverageBlockData > ,
226205 bb_to_bcb : IndexVec < BasicBlock , Option < BasicCoverageBlock > > ,
227206 predecessors : IndexVec < BasicCoverageBlock , BcbPredecessors > ,
228207 successors : IndexVec < BasicCoverageBlock , Vec < BasicCoverageBlock > > ,
229208}
230209
231210impl BasicCoverageBlocks {
232- // TODO(richkadel): remove if not needed
233- //impl<'a, 'tcx> BasicCoverageBlocks<'a, 'tcx> {
234- // pub fn from_mir(mir_body: &'a mut mir::Body<'tcx>) -> Self {
235211 pub fn from_mir ( mir_body : & mir:: Body < ' tcx > ) -> Self {
236212 let len = mir_body. basic_blocks ( ) . len ( ) ;
237213 let mut bcbs = IndexVec :: with_capacity ( len) ;
@@ -395,19 +371,13 @@ impl BasicCoverageBlocks {
395371 } , bcbs. len ( ) ) ;
396372
397373 Self {
398- // mir_body,
399374 bcbs,
400375 bb_to_bcb,
401376 predecessors,
402377 successors,
403378 }
404379 }
405380
406- // TODO(richkadel): remove if not needed
407- // pub fn iter(&self) -> impl Iterator<Item = &BasicCoverageBlockData> {
408- // self.bcbs.iter()
409- // }
410-
411381 pub fn iter_enumerated ( & self ) -> impl Iterator < Item = ( BasicCoverageBlock , & BasicCoverageBlockData ) > {
412382 self . bcbs . iter_enumerated ( )
413383 }
@@ -416,21 +386,6 @@ impl BasicCoverageBlocks {
416386 self . bb_to_bcb [ bb] . expect ( "bb is not in any bcb (pre-filtered, such as unwind paths perhaps?)" )
417387 }
418388
419- // TODO(richkadel): remove if not needed
420- // fn bcb_data_from_bb(&self, bb: BasicBlock) -> &BasicCoverageBlockData {
421- // &self.bcbs[self.bcb_from_bb(bb)]
422- // }
423-
424- // TODO(richkadel): remove if not needed
425- // fn mir_body(&self) -> &mir::Body<'tcx> {
426- // self.mir_body
427- // }
428-
429- // TODO(richkadel): remove if not needed
430- // fn mir_body_mut(&mut self) -> &mut mir::Body<'tcx> {
431- // self.mir_body
432- // }
433-
434389 fn add_basic_coverage_block ( bcbs : & mut IndexVec < BasicCoverageBlock , BasicCoverageBlockData > , bb_to_bcb : & mut IndexVec < BasicBlock , Option < BasicCoverageBlock > > , basic_blocks : Vec < BasicBlock > ) {
435390 let bcb = BasicCoverageBlock :: from_usize ( bcbs. len ( ) ) ;
436391 for & bb in basic_blocks. iter ( ) {
@@ -441,35 +396,23 @@ impl BasicCoverageBlocks {
441396 bcbs. push ( bcb_data) ;
442397 }
443398
444- // TODO(richkadel): remove?
445- // #[inline]
446- // pub fn predecessors(&self) -> impl std::ops::Deref<Target = BcbPredecessors> + '_ {
447- // self.predecessors
448- // }
449-
450399 #[ inline]
451400 pub fn compute_bcb_dominators ( & self ) -> Dominators < BasicCoverageBlock > {
452401 dominators:: dominators ( self )
453402 }
454403}
455404
456- // TODO(richkadel): remove?
457- //impl<'a, 'tcx> graph::DirectedGraph for BasicCoverageBlocks<'a, 'tcx> {
458405impl graph:: DirectedGraph for BasicCoverageBlocks {
459406 type Node = BasicCoverageBlock ;
460407}
461408
462- // TODO(richkadel): remove?
463- //impl<'a, 'tcx> graph::WithNumNodes for BasicCoverageBlocks<'a, 'tcx> {
464409impl graph:: WithNumNodes for BasicCoverageBlocks {
465410 #[ inline]
466411 fn num_nodes ( & self ) -> usize {
467412 self . bcbs . len ( )
468413 }
469414}
470415
471- // TODO(richkadel): remove?
472- //impl<'a, 'tcx> graph::WithStartNode for BasicCoverageBlocks<'a, 'tcx> {
473416impl graph:: WithStartNode for BasicCoverageBlocks {
474417 #[ inline]
475418 fn start_node ( & self ) -> Self :: Node {
@@ -480,53 +423,33 @@ impl graph::WithStartNode for BasicCoverageBlocks {
480423// `BasicBlock` `Predecessors` uses a `SmallVec` of length 4 because, "Typically 95%+ of basic
481424// blocks have 4 or fewer predecessors." BasicCoverageBlocks should have the same or less.
482425type BcbPredecessors = SmallVec < [ BasicCoverageBlock ; 4 ] > ;
483- // TODO(richkadel): remove?
484- //type BcbPredecessors = IndexVec<BasicCoverageBlock, SmallVec<[BasicCoverageBlock; 4]>>;
485426
486427pub type BcbSuccessors < ' a > = std:: slice:: Iter < ' a , BasicCoverageBlock > ;
487- // TODO(richkadel): remove?
488- //pub type BcbSuccessors = std::slice::Iter<'_, BasicCoverageBlock>;
489428
490- // TODO(richkadel): remove?
491- //impl<'a, 'tcx> graph::WithSuccessors for BasicCoverageBlocks<'a, 'tcx> {
492429impl graph:: WithSuccessors for BasicCoverageBlocks {
493430 #[ inline]
494431 fn successors ( & self , node : Self :: Node ) -> <Self as GraphSuccessors < ' _ > >:: Iter {
495432 self . successors [ node] . iter ( ) . cloned ( )
496433 }
497434}
498435
499- // TODO(richkadel): remove?
500- //impl<'a, 'tcx, 'b> graph::GraphSuccessors<'b> for BasicCoverageBlocks<'a, 'tcx> {
501- //impl<'b> graph::GraphSuccessors<'b> for BasicCoverageBlocks {
502436impl < ' a > graph:: GraphSuccessors < ' a > for BasicCoverageBlocks {
503437 type Item = BasicCoverageBlock ;
504- // TODO(richkadel): remove?
505- //type Iter = std::iter::Cloned<BcbSuccessors<'b>>;
506- //type Iter = std::iter::Cloned<BcbSuccessors>;
507438 type Iter = std:: iter:: Cloned < BcbSuccessors < ' a > > ;
508439}
509440
510- // TODO(richkadel): remove?
511- //impl graph::GraphPredecessors<'graph> for BasicCoverageBlocks<'a, 'tcx> {
512441impl graph:: GraphPredecessors < ' graph > for BasicCoverageBlocks {
513442 type Item = BasicCoverageBlock ;
514- // TODO(richkadel): remove?
515- //type Iter = smallvec::IntoIter<BcbPredecessors>;
516443 type Iter = smallvec:: IntoIter < [ BasicCoverageBlock ; 4 ] > ;
517444}
518445
519- // TODO(richkadel): remove?
520- //impl graph::WithPredecessors for BasicCoverageBlocks<'a, 'tcx> {
521446impl graph:: WithPredecessors for BasicCoverageBlocks {
522447 #[ inline]
523448 fn predecessors ( & self , node : Self :: Node ) -> <Self as graph:: GraphPredecessors < ' _ > >:: Iter {
524449 self . predecessors [ node] . clone ( ) . into_iter ( )
525450 }
526451}
527452
528- // TODO(richkadel): remove?
529- //impl<'a, 'tcx> Index<BasicCoverageBlock> for BasicCoverageBlocks<'a, 'tcx> {
530453impl Index < BasicCoverageBlock > for BasicCoverageBlocks {
531454 type Output = BasicCoverageBlockData ;
532455
@@ -536,8 +459,6 @@ impl Index<BasicCoverageBlock> for BasicCoverageBlocks {
536459 }
537460}
538461
539- // TODO(richkadel): remove?
540- //impl<'a, 'tcx> IndexMut<BasicCoverageBlock> for BasicCoverageBlocks<'a, 'tcx> {
541462impl IndexMut < BasicCoverageBlock > for BasicCoverageBlocks {
542463 #[ inline]
543464 fn index_mut ( & mut self , index : BasicCoverageBlock ) -> & mut BasicCoverageBlockData {
@@ -735,8 +656,6 @@ struct Instrumentor<'a, 'tcx> {
735656 mir_body : & ' a mut mir:: Body < ' tcx > ,
736657 hir_body : & ' tcx rustc_hir:: Body < ' tcx > ,
737658 bcb_dominators : Dominators < BasicCoverageBlock > ,
738- //TODO(richkadel): remove?
739- // basic_coverage_blocks: BasicCoverageBlocks<'a, 'tcx>,
740659 basic_coverage_blocks : BasicCoverageBlocks ,
741660 function_source_hash : Option < u64 > ,
742661 next_counter_id : u32 ,
@@ -765,14 +684,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
765684 }
766685 }
767686
768- // fn mir_body(&self) -> &mir::Body<'tcx> {
769- // self.basic_coverage_blocks.mir_body()
770- // }
771-
772- // fn mir_body_mut(&mut self) -> &mut mir::Body<'tcx> {
773- // self.basic_coverage_blocks.mir_body_mut()
774- // }
775-
776687 /// Counter IDs start from one and go up.
777688 fn next_counter ( & mut self ) -> CounterValueReference {
778689 assert ! ( self . next_counter_id < u32 :: MAX - self . num_expressions) ;
@@ -892,8 +803,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
892803 let code_region = make_code_region ( file_name, source_file, span) ;
893804 debug ! ( " injecting statement {:?} covering {:?}" , coverage_kind, code_region) ;
894805
895- // TODO(richkadel): remove?
896- // let data = &mut self.mir_body_mut()[block];
897806 let data = & mut self . mir_body [ block] ;
898807 let source_info = data. terminator ( ) . source_info ;
899808 let statement = Statement {
@@ -927,12 +836,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
927836 span_viewables
928837 }
929838
930- // TODO(richkadel): remove if not needed
931- // #[inline(always)]
932- // fn bcb_from_coverage_span(&self, coverage_span: &CoverageSpan) -> &BasicCoverageBlockData {
933- // &self.basic_coverage_blocks[coverage_span.bcb]
934- // }
935-
936839 #[ inline( always) ]
937840 fn body_span ( & self ) -> Span {
938841 self . hir_body . value . span
0 commit comments