@@ -4,7 +4,7 @@ use std::collections::hash_map::Entry;
44use rustc_data_structures:: fx:: FxHashMap ;
55use rustc_index:: IndexVec ;
66use rustc_middle:: mir:: coverage:: {
7- BlockMarkerId , BranchSpan , ConditionId , CoverageKind , DecisionId , DecisionSpan ,
7+ BlockMarkerId , BranchSpan , ConditionMarkerId , CoverageKind , DecisionMarkerId , DecisionSpan ,
88} ;
99use rustc_middle:: mir:: { self , BasicBlock , UnOp } ;
1010use rustc_middle:: thir:: { ExprId , ExprKind , Thir } ;
@@ -19,12 +19,12 @@ struct MCDCInfoBuilder {
1919 /// ID of the current decision.
2020 /// Do not use directly. Use the function instead, as it will hide
2121 /// the decision in the scope of nested decisions.
22- current_decision_id : Option < DecisionId > ,
22+ current_decision_id : Option < DecisionMarkerId > ,
2323 /// Track the nesting level of decision to avoid MCDC instrumentation of
2424 /// nested decisions.
2525 nested_decision_level : u32 ,
2626 /// Vector for storing all the decisions with their span
27- decision_spans : IndexVec < DecisionId , Span > ,
27+ decision_spans : IndexVec < DecisionMarkerId , Span > ,
2828
2929 next_condition_id : u32 ,
3030}
@@ -52,7 +52,7 @@ impl MCDCInfoBuilder {
5252 self . nested_decision_level > 1
5353 }
5454
55- pub fn current_decision_id ( & self ) -> Option < DecisionId > {
55+ pub fn current_decision_id ( & self ) -> Option < DecisionMarkerId > {
5656 if self . in_nested_condition ( ) { None } else { self . current_decision_id }
5757 }
5858
@@ -235,7 +235,7 @@ impl Builder<'_, '_> {
235235 . mcdc_info
236236 . as_ref ( )
237237 . and_then ( |mcdc_info| mcdc_info. current_decision_id ( ) )
238- . unwrap_or ( DecisionId :: from_u32 ( 0 ) ) ,
238+ . unwrap_or ( DecisionMarkerId :: from_u32 ( 0 ) ) ,
239239 true_marker,
240240 false_marker,
241241 } ) ;
@@ -268,7 +268,7 @@ impl Builder<'_, '_> {
268268 let marker_statement = mir:: Statement {
269269 source_info,
270270 kind : mir:: StatementKind :: Coverage ( CoverageKind :: MCDCDecisionEntryMarker {
271- id : decision_id,
271+ decm_id : decision_id,
272272 } ) ,
273273 } ;
274274 self . cfg . push ( block, marker_statement) ;
@@ -290,43 +290,31 @@ impl Builder<'_, '_> {
290290 /// If MCDC is enabled and the current decision is being instrumented,
291291 /// inject an `MCDCDecisionOutputMarker` to the given basic block.
292292 /// `outcome` should be true for the then block and false for the else block.
293- pub ( crate ) fn mcdc_decision_outcome_block (
294- & mut self ,
295- bb : BasicBlock ,
296- outcome : bool ,
297- ) -> BasicBlock {
293+ pub ( crate ) fn mcdc_decision_outcome_block ( & mut self , bb : BasicBlock , outcome : bool ) {
298294 // Get the MCDCInfoBuilder object, which existence implies that MCDC is enabled.
299295 let Some ( BranchInfoBuilder { mcdc_info : Some ( mcdc_info) , .. } ) =
300296 self . coverage_branch_info . as_mut ( )
301297 else {
302- return bb ;
298+ return ;
303299 } ;
304300
305301 let Some ( decision_id) = mcdc_info. current_decision_id ( ) else {
306302 // Decision is not instrumented
307- return bb ;
303+ return ;
308304 } ;
309305
310306 let span = mcdc_info. decision_spans [ decision_id] ;
311307 let source_info = self . source_info ( span) ;
312308 let marker_statement = mir:: Statement {
313309 source_info,
314310 kind : mir:: StatementKind :: Coverage ( CoverageKind :: MCDCDecisionOutputMarker {
315- id : decision_id,
311+ decm_id : decision_id,
316312 outcome,
317313 } ) ,
318314 } ;
319315
320316 // Insert statements at the beginning of the following basic block
321317 self . cfg . block_data_mut ( bb) . statements . insert ( 0 , marker_statement) ;
322-
323- // Create a new block to return
324- let new_bb = self . cfg . start_new_block ( ) ;
325-
326- // Set bb -> new_bb
327- self . cfg . goto ( bb, source_info, new_bb) ;
328-
329- new_bb
330318 }
331319
332320 /// Add markers on the condition's basic blocks to ease the later MCDC instrumentation.
@@ -344,13 +332,12 @@ impl Builder<'_, '_> {
344332 return ;
345333 } ;
346334
347- let Some ( decision_id ) = mcdc_info. current_decision_id ( ) else {
335+ let Some ( decm_id ) = mcdc_info. current_decision_id ( ) else {
348336 // If current_decision_id() is None, the decision is not instrumented.
349337 return ;
350338 } ;
351339
352-
353- let id = ConditionId :: from_u32 ( mcdc_info. next_condition_id ( ) ) ;
340+ let condm_id = ConditionMarkerId :: from_u32 ( mcdc_info. next_condition_id ( ) ) ;
354341 let span = self . thir [ condition_expr] . span ;
355342 let source_info = self . source_info ( span) ;
356343
@@ -362,15 +349,15 @@ impl Builder<'_, '_> {
362349
363350 inject_statement (
364351 condition_block,
365- CoverageKind :: MCDCConditionEntryMarker { decision_id , id } ,
352+ CoverageKind :: MCDCConditionEntryMarker { decm_id , condm_id } ,
366353 ) ;
367354 inject_statement (
368355 then_block,
369- CoverageKind :: MCDCConditionOutputMarker { decision_id , id , outcome : true } ,
356+ CoverageKind :: MCDCConditionOutputMarker { decm_id , condm_id , outcome : true } ,
370357 ) ;
371358 inject_statement (
372359 else_block,
373- CoverageKind :: MCDCConditionOutputMarker { decision_id , id , outcome : false } ,
360+ CoverageKind :: MCDCConditionOutputMarker { decm_id , condm_id , outcome : false } ,
374361 ) ;
375362 }
376363}
0 commit comments