29
29
30
30
use crate :: transform:: MirPass ;
31
31
use rustc_index:: vec:: { Idx , IndexVec } ;
32
- use rustc_middle:: mir:: coverage:: * ;
33
32
use rustc_middle:: mir:: visit:: { MutVisitor , MutatingUseContext , PlaceContext , Visitor } ;
34
33
use rustc_middle:: mir:: * ;
35
34
use rustc_middle:: ty:: TyCtxt ;
@@ -47,9 +46,9 @@ impl SimplifyCfg {
47
46
}
48
47
}
49
48
50
- pub fn simplify_cfg ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' _ > ) {
49
+ pub fn simplify_cfg ( body : & mut Body < ' _ > ) {
51
50
CfgSimplifier :: new ( body) . simplify ( ) ;
52
- remove_dead_blocks ( tcx , body) ;
51
+ remove_dead_blocks ( body) ;
53
52
54
53
// FIXME: Should probably be moved into some kind of pass manager
55
54
body. basic_blocks_mut ( ) . raw . shrink_to_fit ( ) ;
@@ -60,9 +59,9 @@ impl<'tcx> MirPass<'tcx> for SimplifyCfg {
60
59
Cow :: Borrowed ( & self . label )
61
60
}
62
61
63
- fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
62
+ fn run_pass ( & self , _tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
64
63
debug ! ( "SimplifyCfg({:?}) - simplifying {:?}" , self . label, body. source) ;
65
- simplify_cfg ( tcx , body) ;
64
+ simplify_cfg ( body) ;
66
65
}
67
66
}
68
67
@@ -287,7 +286,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
287
286
}
288
287
}
289
288
290
- pub fn remove_dead_blocks ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' _ > ) {
289
+ pub fn remove_dead_blocks ( body : & mut Body < ' _ > ) {
291
290
let reachable = traversal:: reachable_as_bitset ( body) ;
292
291
let num_blocks = body. basic_blocks ( ) . len ( ) ;
293
292
if num_blocks == reachable. count ( ) {
@@ -307,11 +306,6 @@ pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
307
306
}
308
307
used_blocks += 1 ;
309
308
}
310
-
311
- if tcx. sess . instrument_coverage ( ) {
312
- save_unreachable_coverage ( basic_blocks, used_blocks) ;
313
- }
314
-
315
309
basic_blocks. raw . truncate ( used_blocks) ;
316
310
317
311
for block in basic_blocks {
@@ -321,32 +315,6 @@ pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
321
315
}
322
316
}
323
317
324
- fn save_unreachable_coverage (
325
- basic_blocks : & mut IndexVec < BasicBlock , BasicBlockData < ' _ > > ,
326
- first_dead_block : usize ,
327
- ) {
328
- // retain coverage info for dead blocks, so coverage reports will still
329
- // report `0` executions for the uncovered code regions.
330
- let mut dropped_coverage = Vec :: new ( ) ;
331
- for dead_block in first_dead_block..basic_blocks. len ( ) {
332
- for statement in basic_blocks[ BasicBlock :: new ( dead_block) ] . statements . iter ( ) {
333
- if let StatementKind :: Coverage ( coverage) = & statement. kind {
334
- if let Some ( code_region) = & coverage. code_region {
335
- dropped_coverage. push ( ( statement. source_info , code_region. clone ( ) ) ) ;
336
- }
337
- }
338
- }
339
- }
340
- for ( source_info, code_region) in dropped_coverage {
341
- basic_blocks[ START_BLOCK ] . statements . push ( Statement {
342
- source_info,
343
- kind : StatementKind :: Coverage ( box Coverage {
344
- kind : CoverageKind :: Unreachable ,
345
- code_region : Some ( code_region) ,
346
- } ) ,
347
- } )
348
- }
349
- }
350
318
pub struct SimplifyLocals ;
351
319
352
320
impl < ' tcx > MirPass < ' tcx > for SimplifyLocals {
0 commit comments