@@ -4,12 +4,8 @@ use crate::util::spanview::{self, SpanViewable};
4
4
5
5
use rustc_data_structures:: fingerprint:: Fingerprint ;
6
6
use rustc_data_structures:: graph:: dominators:: { self , Dominators } ;
7
- // TODO(richkadel): remove?
8
- //use rustc_data_structures::graph::{self, GraphSuccessors, WithSuccessors};
9
7
use rustc_data_structures:: graph:: { self , GraphSuccessors } ;
10
8
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
11
- // TODO(richkadel): remove?
12
- //use rustc_data_structures::sync::{Lrc, OnceCell};
13
9
use rustc_data_structures:: sync:: Lrc ;
14
10
use rustc_index:: bit_set:: BitSet ;
15
11
use rustc_index:: vec:: IndexVec ;
@@ -29,7 +25,6 @@ use rustc_span::def_id::DefId;
29
25
use rustc_span:: source_map:: original_sp;
30
26
use rustc_span:: { BytePos , CharPos , Pos , SourceFile , Span , Symbol , SyntaxContext } ;
31
27
32
- // TODO(richkadel): remove?
33
28
use smallvec:: SmallVec ;
34
29
35
30
use std:: cmp:: Ordering ;
@@ -198,40 +193,21 @@ impl BasicCoverageBlockData {
198
193
}
199
194
}
200
195
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
-
210
196
rustc_index:: newtype_index! {
211
197
/// A node in the [control-flow graph][CFG] of BasicCoverageBlocks.
212
198
pub struct BasicCoverageBlock {
213
- // TODO(richkadel): remove if not needed
214
- // derive [HashStable]
215
199
DEBUG_FORMAT = "bcb{}" ,
216
- // TODO(richkadel): remove if not needed
217
- // const START_BLOCK = 0,
218
200
}
219
201
}
220
202
221
203
struct BasicCoverageBlocks {
222
- // TODO(richkadel): remove if not needed
223
- // struct BasicCoverageBlocks<'a, 'tcx> {
224
- // mir_body: &'a mut mir::Body<'tcx>,
225
204
bcbs : IndexVec < BasicCoverageBlock , BasicCoverageBlockData > ,
226
205
bb_to_bcb : IndexVec < BasicBlock , Option < BasicCoverageBlock > > ,
227
206
predecessors : IndexVec < BasicCoverageBlock , BcbPredecessors > ,
228
207
successors : IndexVec < BasicCoverageBlock , Vec < BasicCoverageBlock > > ,
229
208
}
230
209
231
210
impl 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 {
235
211
pub fn from_mir ( mir_body : & mir:: Body < ' tcx > ) -> Self {
236
212
let len = mir_body. basic_blocks ( ) . len ( ) ;
237
213
let mut bcbs = IndexVec :: with_capacity ( len) ;
@@ -395,19 +371,13 @@ impl BasicCoverageBlocks {
395
371
} , bcbs. len ( ) ) ;
396
372
397
373
Self {
398
- // mir_body,
399
374
bcbs,
400
375
bb_to_bcb,
401
376
predecessors,
402
377
successors,
403
378
}
404
379
}
405
380
406
- // TODO(richkadel): remove if not needed
407
- // pub fn iter(&self) -> impl Iterator<Item = &BasicCoverageBlockData> {
408
- // self.bcbs.iter()
409
- // }
410
-
411
381
pub fn iter_enumerated ( & self ) -> impl Iterator < Item = ( BasicCoverageBlock , & BasicCoverageBlockData ) > {
412
382
self . bcbs . iter_enumerated ( )
413
383
}
@@ -416,21 +386,6 @@ impl BasicCoverageBlocks {
416
386
self . bb_to_bcb [ bb] . expect ( "bb is not in any bcb (pre-filtered, such as unwind paths perhaps?)" )
417
387
}
418
388
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
-
434
389
fn add_basic_coverage_block ( bcbs : & mut IndexVec < BasicCoverageBlock , BasicCoverageBlockData > , bb_to_bcb : & mut IndexVec < BasicBlock , Option < BasicCoverageBlock > > , basic_blocks : Vec < BasicBlock > ) {
435
390
let bcb = BasicCoverageBlock :: from_usize ( bcbs. len ( ) ) ;
436
391
for & bb in basic_blocks. iter ( ) {
@@ -441,35 +396,23 @@ impl BasicCoverageBlocks {
441
396
bcbs. push ( bcb_data) ;
442
397
}
443
398
444
- // TODO(richkadel): remove?
445
- // #[inline]
446
- // pub fn predecessors(&self) -> impl std::ops::Deref<Target = BcbPredecessors> + '_ {
447
- // self.predecessors
448
- // }
449
-
450
399
#[ inline]
451
400
pub fn compute_bcb_dominators ( & self ) -> Dominators < BasicCoverageBlock > {
452
401
dominators:: dominators ( self )
453
402
}
454
403
}
455
404
456
- // TODO(richkadel): remove?
457
- //impl<'a, 'tcx> graph::DirectedGraph for BasicCoverageBlocks<'a, 'tcx> {
458
405
impl graph:: DirectedGraph for BasicCoverageBlocks {
459
406
type Node = BasicCoverageBlock ;
460
407
}
461
408
462
- // TODO(richkadel): remove?
463
- //impl<'a, 'tcx> graph::WithNumNodes for BasicCoverageBlocks<'a, 'tcx> {
464
409
impl graph:: WithNumNodes for BasicCoverageBlocks {
465
410
#[ inline]
466
411
fn num_nodes ( & self ) -> usize {
467
412
self . bcbs . len ( )
468
413
}
469
414
}
470
415
471
- // TODO(richkadel): remove?
472
- //impl<'a, 'tcx> graph::WithStartNode for BasicCoverageBlocks<'a, 'tcx> {
473
416
impl graph:: WithStartNode for BasicCoverageBlocks {
474
417
#[ inline]
475
418
fn start_node ( & self ) -> Self :: Node {
@@ -480,53 +423,33 @@ impl graph::WithStartNode for BasicCoverageBlocks {
480
423
// `BasicBlock` `Predecessors` uses a `SmallVec` of length 4 because, "Typically 95%+ of basic
481
424
// blocks have 4 or fewer predecessors." BasicCoverageBlocks should have the same or less.
482
425
type BcbPredecessors = SmallVec < [ BasicCoverageBlock ; 4 ] > ;
483
- // TODO(richkadel): remove?
484
- //type BcbPredecessors = IndexVec<BasicCoverageBlock, SmallVec<[BasicCoverageBlock; 4]>>;
485
426
486
427
pub type BcbSuccessors < ' a > = std:: slice:: Iter < ' a , BasicCoverageBlock > ;
487
- // TODO(richkadel): remove?
488
- //pub type BcbSuccessors = std::slice::Iter<'_, BasicCoverageBlock>;
489
428
490
- // TODO(richkadel): remove?
491
- //impl<'a, 'tcx> graph::WithSuccessors for BasicCoverageBlocks<'a, 'tcx> {
492
429
impl graph:: WithSuccessors for BasicCoverageBlocks {
493
430
#[ inline]
494
431
fn successors ( & self , node : Self :: Node ) -> <Self as GraphSuccessors < ' _ > >:: Iter {
495
432
self . successors [ node] . iter ( ) . cloned ( )
496
433
}
497
434
}
498
435
499
- // TODO(richkadel): remove?
500
- //impl<'a, 'tcx, 'b> graph::GraphSuccessors<'b> for BasicCoverageBlocks<'a, 'tcx> {
501
- //impl<'b> graph::GraphSuccessors<'b> for BasicCoverageBlocks {
502
436
impl < ' a > graph:: GraphSuccessors < ' a > for BasicCoverageBlocks {
503
437
type Item = BasicCoverageBlock ;
504
- // TODO(richkadel): remove?
505
- //type Iter = std::iter::Cloned<BcbSuccessors<'b>>;
506
- //type Iter = std::iter::Cloned<BcbSuccessors>;
507
438
type Iter = std:: iter:: Cloned < BcbSuccessors < ' a > > ;
508
439
}
509
440
510
- // TODO(richkadel): remove?
511
- //impl graph::GraphPredecessors<'graph> for BasicCoverageBlocks<'a, 'tcx> {
512
441
impl graph:: GraphPredecessors < ' graph > for BasicCoverageBlocks {
513
442
type Item = BasicCoverageBlock ;
514
- // TODO(richkadel): remove?
515
- //type Iter = smallvec::IntoIter<BcbPredecessors>;
516
443
type Iter = smallvec:: IntoIter < [ BasicCoverageBlock ; 4 ] > ;
517
444
}
518
445
519
- // TODO(richkadel): remove?
520
- //impl graph::WithPredecessors for BasicCoverageBlocks<'a, 'tcx> {
521
446
impl graph:: WithPredecessors for BasicCoverageBlocks {
522
447
#[ inline]
523
448
fn predecessors ( & self , node : Self :: Node ) -> <Self as graph:: GraphPredecessors < ' _ > >:: Iter {
524
449
self . predecessors [ node] . clone ( ) . into_iter ( )
525
450
}
526
451
}
527
452
528
- // TODO(richkadel): remove?
529
- //impl<'a, 'tcx> Index<BasicCoverageBlock> for BasicCoverageBlocks<'a, 'tcx> {
530
453
impl Index < BasicCoverageBlock > for BasicCoverageBlocks {
531
454
type Output = BasicCoverageBlockData ;
532
455
@@ -536,8 +459,6 @@ impl Index<BasicCoverageBlock> for BasicCoverageBlocks {
536
459
}
537
460
}
538
461
539
- // TODO(richkadel): remove?
540
- //impl<'a, 'tcx> IndexMut<BasicCoverageBlock> for BasicCoverageBlocks<'a, 'tcx> {
541
462
impl IndexMut < BasicCoverageBlock > for BasicCoverageBlocks {
542
463
#[ inline]
543
464
fn index_mut ( & mut self , index : BasicCoverageBlock ) -> & mut BasicCoverageBlockData {
@@ -735,8 +656,6 @@ struct Instrumentor<'a, 'tcx> {
735
656
mir_body : & ' a mut mir:: Body < ' tcx > ,
736
657
hir_body : & ' tcx rustc_hir:: Body < ' tcx > ,
737
658
bcb_dominators : Dominators < BasicCoverageBlock > ,
738
- //TODO(richkadel): remove?
739
- // basic_coverage_blocks: BasicCoverageBlocks<'a, 'tcx>,
740
659
basic_coverage_blocks : BasicCoverageBlocks ,
741
660
function_source_hash : Option < u64 > ,
742
661
next_counter_id : u32 ,
@@ -765,14 +684,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
765
684
}
766
685
}
767
686
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
-
776
687
/// Counter IDs start from one and go up.
777
688
fn next_counter ( & mut self ) -> CounterValueReference {
778
689
assert ! ( self . next_counter_id < u32 :: MAX - self . num_expressions) ;
@@ -892,8 +803,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
892
803
let code_region = make_code_region ( file_name, source_file, span) ;
893
804
debug ! ( " injecting statement {:?} covering {:?}" , coverage_kind, code_region) ;
894
805
895
- // TODO(richkadel): remove?
896
- // let data = &mut self.mir_body_mut()[block];
897
806
let data = & mut self . mir_body [ block] ;
898
807
let source_info = data. terminator ( ) . source_info ;
899
808
let statement = Statement {
@@ -927,12 +836,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
927
836
span_viewables
928
837
}
929
838
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
-
936
839
#[ inline( always) ]
937
840
fn body_span ( & self ) -> Span {
938
841
self . hir_body . value . span
0 commit comments