Implement Modified Condition/Decision Coverage#123409
Merged
bors merged 4 commits intorust-lang:masterfrom Apr 20, 2024
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an implementation based on llvm backend support (>= 18) by @evodius96 and branch coverage support by @Zalathar.
Major changes:
no-branch,branch, ormcdc.mcdcalso enablesbranchbecause it is essential to work.Implementation Details
MCDCStateinBranchInfoBuilderis used during hir lowering to mir. For expressions with logical op we callBuilder::visit_coverage_branch_operationto record its sub conditions, generate condition ids for them and save their spans (to construct the span of whole decision). This process mainly references to the implementation in clang and is described in comments overMCDCState::record_conditions. Also true marks and false marks introduced by branch coverage are used to detect where the decision evaluation ends: the next id of the condition == 0.MCDCState::decision_stackpopped all recorded conditions, we can ensure that the decision is checked over and push it intodecision_spans. We do not manually insert decision span to avoid complexity from then_else_break in nested if scopes.CondBitmapUpdatestatements to its evaluated blocks. While decision bcb mapping will insertTestVectorBitmapUpdatein all its end blocks.Usage
to build the compiler and run tests.
to check "foo" code.
Problems to solve
For now decision mapping will insert statements to its all end blocks, which may be optimized by inserting a final block of the decision. To do this we must also trace the evaluated value at each end of the decision and join them separately.
This implementation is not heavily tested so there should be some unrevealed issues. We are going to check our rust products in the next. Please let me know if you had any suggestions or comments.