@@ -25,7 +25,7 @@ use rustc_span::source_map::SourceMap;
2525use rustc_span:: { BytePos , Pos , RelativeBytePos , Span , Symbol } ;
2626
2727use crate :: coverage:: counters:: { CounterIncrementSite , CoverageCounters } ;
28- use crate :: coverage:: graph:: CoverageGraph ;
28+ use crate :: coverage:: graph:: { BasicCoverageBlock , CoverageGraph } ;
2929use crate :: coverage:: mappings:: ExtractedMappings ;
3030use crate :: MirPass ;
3131
@@ -98,14 +98,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
9898 let mut coverage_counters =
9999 CoverageCounters :: make_bcb_counters ( & basic_coverage_blocks, bcb_has_counter_mappings) ;
100100
101- let mappings = create_mappings (
102- mir_body,
103- tcx,
104- & hir_info,
105- & extracted_mappings,
106- & basic_coverage_blocks,
107- & mut coverage_counters,
108- ) ;
101+ let mappings = create_mappings ( tcx, & hir_info, & extracted_mappings, & mut coverage_counters) ;
109102 if mappings. is_empty ( ) {
110103 // No spans could be converted into valid mappings, so skip this function.
111104 debug ! ( "no spans could be converted into valid mappings; skipping" ) ;
@@ -144,11 +137,9 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
144137/// Precondition: All BCBs corresponding to those spans have been given
145138/// coverage counters.
146139fn create_mappings < ' tcx > (
147- mir_body : & mut mir:: Body < ' tcx > ,
148140 tcx : TyCtxt < ' tcx > ,
149141 hir_info : & ExtractedHirInfo ,
150142 extracted_mappings : & ExtractedMappings ,
151- basic_coverage_blocks : & CoverageGraph ,
152143 coverage_counters : & mut CoverageCounters ,
153144) -> Vec < Mapping > {
154145 let source_map = tcx. sess . source_map ( ) ;
@@ -198,7 +189,7 @@ fn create_mappings<'tcx>(
198189 Some ( Mapping { kind, code_region } )
199190 } ,
200191 ) ) ;
201- let mut term_for_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
192+ let mut term_for_sum_of_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
202193 let counters = bcbs
203194 . into_iter ( )
204195 . copied ( )
@@ -210,28 +201,15 @@ fn create_mappings<'tcx>(
210201 . into_iter ( )
211202 . fold ( None , |acc, val| Some ( coverage_counters. make_sum_expression ( acc, val) ) )
212203 . expect ( "counters must be non-empty" ) ;
213- // Since the counter is a sum of multiple counters, it should be marked used in
214- // all associated bcbs in case it were markered as `Zero`.
215- if bcbs. len ( ) > 1
216- && let counters:: BcbCounter :: Expression { id } = counter
217- {
218- for & bcb in bcbs {
219- inject_statement (
220- mir_body,
221- CoverageKind :: ExpressionUsed { id } ,
222- basic_coverage_blocks[ bcb] . leader_bb ( ) ,
223- ) ;
224- }
225- }
226204 counter. as_term ( )
227205 } ;
228206
229207 // MCDC branch mappings are appended with their decisions in case decisions were ignored.
230208 mappings. extend ( mcdc_degraded_branches. iter ( ) . filter_map (
231209 |& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info : _ } | {
232210 let code_region = region_for_span ( span) ?;
233- let true_term = term_for_bcbs ( true_bcbs) ;
234- let false_term = term_for_bcbs ( false_bcbs) ;
211+ let true_term = term_for_sum_of_bcbs ( true_bcbs) ;
212+ let false_term = term_for_sum_of_bcbs ( false_bcbs) ;
235213 Some ( Mapping { kind : MappingKind :: Branch { true_term, false_term } , code_region } )
236214 } ,
237215 ) ) ;
@@ -243,8 +221,8 @@ fn create_mappings<'tcx>(
243221 . filter_map (
244222 |& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info } | {
245223 let code_region = region_for_span ( span) ?;
246- let true_term = term_for_bcbs ( true_bcbs) ;
247- let false_term = term_for_bcbs ( false_bcbs) ;
224+ let true_term = term_for_sum_of_bcbs ( true_bcbs) ;
225+ let false_term = term_for_sum_of_bcbs ( false_bcbs) ;
248226 Some ( Mapping {
249227 kind : MappingKind :: MCDCBranch {
250228 true_term,
0 commit comments