@@ -25,7 +25,7 @@ use rustc_span::source_map::SourceMap;
25
25
use rustc_span:: { BytePos , Pos , RelativeBytePos , Span , Symbol } ;
26
26
27
27
use crate :: coverage:: counters:: { CounterIncrementSite , CoverageCounters } ;
28
- use crate :: coverage:: graph:: CoverageGraph ;
28
+ use crate :: coverage:: graph:: { BasicCoverageBlock , CoverageGraph } ;
29
29
use crate :: coverage:: mappings:: ExtractedMappings ;
30
30
use crate :: MirPass ;
31
31
@@ -98,14 +98,7 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
98
98
let mut coverage_counters =
99
99
CoverageCounters :: make_bcb_counters ( & basic_coverage_blocks, bcb_has_counter_mappings) ;
100
100
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) ;
109
102
if mappings. is_empty ( ) {
110
103
// No spans could be converted into valid mappings, so skip this function.
111
104
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:
144
137
/// Precondition: All BCBs corresponding to those spans have been given
145
138
/// coverage counters.
146
139
fn create_mappings < ' tcx > (
147
- mir_body : & mut mir:: Body < ' tcx > ,
148
140
tcx : TyCtxt < ' tcx > ,
149
141
hir_info : & ExtractedHirInfo ,
150
142
extracted_mappings : & ExtractedMappings ,
151
- basic_coverage_blocks : & CoverageGraph ,
152
143
coverage_counters : & mut CoverageCounters ,
153
144
) -> Vec < Mapping > {
154
145
let source_map = tcx. sess . source_map ( ) ;
@@ -198,7 +189,7 @@ fn create_mappings<'tcx>(
198
189
Some ( Mapping { kind, code_region } )
199
190
} ,
200
191
) ) ;
201
- let mut term_for_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
192
+ let mut term_for_sum_of_bcbs = |bcbs : & [ BasicCoverageBlock ] | {
202
193
let counters = bcbs
203
194
. into_iter ( )
204
195
. copied ( )
@@ -210,28 +201,15 @@ fn create_mappings<'tcx>(
210
201
. into_iter ( )
211
202
. fold ( None , |acc, val| Some ( coverage_counters. make_sum_expression ( acc, val) ) )
212
203
. 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
- }
226
204
counter. as_term ( )
227
205
} ;
228
206
229
207
// MCDC branch mappings are appended with their decisions in case decisions were ignored.
230
208
mappings. extend ( mcdc_degraded_branches. iter ( ) . filter_map (
231
209
|& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info : _ } | {
232
210
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) ;
235
213
Some ( Mapping { kind : MappingKind :: Branch { true_term, false_term } , code_region } )
236
214
} ,
237
215
) ) ;
@@ -243,8 +221,8 @@ fn create_mappings<'tcx>(
243
221
. filter_map (
244
222
|& mappings:: MCDCBranch { span, ref true_bcbs, ref false_bcbs, condition_info } | {
245
223
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) ;
248
226
Some ( Mapping {
249
227
kind : MappingKind :: MCDCBranch {
250
228
true_term,
0 commit comments