-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coverage: Clean up mcdc_bitmap_bytes
and conditions_num
#124571
Conversation
rustbot has assigned @compiler-errors. Use |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
It might be possible to adjust the calculation of MC/DC bitmap bytes so that it takes into account which MC/DC coverage statements have survived MIR optimizations, to potentially use fewer bytes. But in the current state of the MC/DC implementation, I don't think the extra complexity is worth it. (The main reason we do this sort of thing for the existing coverage statements is that things already worked that way before I started modifying it, and I didn't want to regress that particular property of the instrumented output.) |
This comment has been minimized.
This comment has been minimized.
15ca582
to
316f7d6
Compare
coverage: Split out MC/DC mappings from `BcbMappingKind` These variants were added to `BcbMappingKind` as part of the [MC/DC coverage](https://en.wikipedia.org/wiki/Modified_Condition/Decision_Coverage) implementation in rust-lang#123409, because that was the path-of-least-resistance for integrating them into the existing code. However, they ultimately represent complex concepts that the enum was not intended to handle, leading to more complexity in the code that processes them. This PR therefore follows in the footsteps of rust-lang#124545, and splits the MC/DC mappings out into their own dedicated vectors of structs. After that, `BcbMappingKind` itself ends up having only one variant (`Code`), so this PR also flattens that enum into its enclosing struct, renamed to `mapping::CodeMapping`. --- No functional changes. This will conflict slightly with rust-lang#124571, but hopefully that should be easy to resolve either way. `@rustbot` label +A-code-coverage
☔ The latest upstream changes (presumably #124603) made this pull request unmergeable. Please resolve the merge conflicts. |
This code for recalculating `mcdc_bitmap_bytes` doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass.
These comments appear to be inspired by the similar comments on `CounterIncrement` and `ExpressionUsed`. But those comments refer to specific simplification steps performed during coverage codegen, and there is no corresponding step for the MC/DC coverage statements.
This field counts the number of conditions that contribute to a particular decision, but the name "conditions num" sounds like an ID instead of a count, so "num conditions" is clearer.
@bors r+ |
…r-errors coverage: Clean up `mcdc_bitmap_bytes` and `conditions_num` This is a combination of two mostly-separate MC/DC coverage cleanups that would conflict with each other, plus some extra tests that appeared along the way. The first change is to stop recomputing `mcdc_bitmap_bytes` in the query that produces `CoverageIdsInfo`. This appears to have been inspired by how we were already computing `max_counter_id`, but there's an important difference between the two cases. When computing `max_counter_id`, the highest counter ID seen might be less than the highest ID used during MIR instrumentation, because some counter-increment statements might have been removed by MIR optimizations. But for the recomputation used for `mcdc_bitmap_bytes`, that's impossible, because both computations are based on pre-optimization info. So there's no need to recompute the exact same value, when it can't have changed --- The second change is to rename `conditions_num` to `num_conditions`, to make it clearer that this refers to a *number of conditions*, not some kind of ID number. Because this change touched the compiler warning for a decision containing too many conditions, I also noticed that we didn't have any tests for that warning. (It now seems a bit strange to me that this is a compiler warning, not a lint, because it can't be silenced or denied by the usual mechanisms for controlling lints. But I consider that change to be beyond the scope of this PR.)
…r-errors coverage: Clean up `mcdc_bitmap_bytes` and `conditions_num` This is a combination of two mostly-separate MC/DC coverage cleanups that would conflict with each other, plus some extra tests that appeared along the way. The first change is to stop recomputing `mcdc_bitmap_bytes` in the query that produces `CoverageIdsInfo`. This appears to have been inspired by how we were already computing `max_counter_id`, but there's an important difference between the two cases. When computing `max_counter_id`, the highest counter ID seen might be less than the highest ID used during MIR instrumentation, because some counter-increment statements might have been removed by MIR optimizations. But for the recomputation used for `mcdc_bitmap_bytes`, that's impossible, because both computations are based on pre-optimization info. So there's no need to recompute the exact same value, when it can't have changed --- The second change is to rename `conditions_num` to `num_conditions`, to make it clearer that this refers to a *number of conditions*, not some kind of ID number. Because this change touched the compiler warning for a decision containing too many conditions, I also noticed that we didn't have any tests for that warning. (It now seems a bit strange to me that this is a compiler warning, not a lint, because it can't be silenced or denied by the usual mechanisms for controlling lints. But I consider that change to be beyond the scope of this PR.)
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#124223 (coverage: Branch coverage support for let-else and if-let) - rust-lang#124571 (coverage: Clean up `mcdc_bitmap_bytes` and `conditions_num`) - rust-lang#124838 (next_power_of_two: add a doctest to show what happens on 0) r? `@ghost` `@rustbot` modify labels: rollup
…errors coverage: Clean up `mcdc_bitmap_bytes` and `conditions_num` This is a combination of two mostly-separate MC/DC coverage cleanups that would conflict with each other, plus some extra tests that appeared along the way. The first change is to stop recomputing `mcdc_bitmap_bytes` in the query that produces `CoverageIdsInfo`. This appears to have been inspired by how we were already computing `max_counter_id`, but there's an important difference between the two cases. When computing `max_counter_id`, the highest counter ID seen might be less than the highest ID used during MIR instrumentation, because some counter-increment statements might have been removed by MIR optimizations. But for the recomputation used for `mcdc_bitmap_bytes`, that's impossible, because both computations are based on pre-optimization info. So there's no need to recompute the exact same value, when it can't have changed --- The second change is to rename `conditions_num` to `num_conditions`, to make it clearer that this refers to a *number of conditions*, not some kind of ID number. Because this change touched the compiler warning for a decision containing too many conditions, I also noticed that we didn't have any tests for that warning. (It now seems a bit strange to me that this is a compiler warning, not a lint, because it can't be silenced or denied by the usual mechanisms for controlling lints. But I consider that change to be beyond the scope of this PR.)
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
Looks like the overflow bug already existed before this PR; it just now gets exercised by the newly-added test (but only in compiler builds with overflow checks). The overflow itself is pretty benign in known cases, since we overflow by -1 and then immediately add 1 again to get back to 0. But it also prevents us from detecting more serious overflow bugs. |
☔ The latest upstream changes (presumably #124972) made this pull request unmergeable. Please resolve the merge conflicts. |
Maybe rewrite the operation |
…hercote coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never needed This code for recalculating `mcdc_bitmap_bytes` in a query doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass. Extracted from rust-lang#124571, to avoid having this held up by unrelated issues with condition count checks. `@rustbot` label +A-code-coverage
Rollup merge of rust-lang#125108 - Zalathar:info-bitmap-bytes, r=nnethercote coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never needed This code for recalculating `mcdc_bitmap_bytes` in a query doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass. Extracted from rust-lang#124571, to avoid having this held up by unrelated issues with condition count checks. `@rustbot` label +A-code-coverage
@rustbot author |
…cote coverage: Avoid overflow when the MC/DC condition limit is exceeded Fix for the test failure seen in rust-lang#124571 (comment). If we perform this subtraction first, it can sometimes overflow to -1 before the addition can bring its value back to 0. That behaviour seems to be benign, but it nevertheless causes test failures in compiler configurations that check for overflow. `@rustbot` label +A-code-coverage
…cote coverage: Avoid overflow when the MC/DC condition limit is exceeded Fix for the test failure seen in rust-lang#124571 (comment). If we perform this subtraction first, it can sometimes overflow to -1 before the addition can bring its value back to 0. That behaviour seems to be benign, but it nevertheless causes test failures in compiler configurations that check for overflow. ``@rustbot`` label +A-code-coverage
Rollup merge of rust-lang#125700 - Zalathar:limit-overflow, r=nnethercote coverage: Avoid overflow when the MC/DC condition limit is exceeded Fix for the test failure seen in rust-lang#124571 (comment). If we perform this subtraction first, it can sometimes overflow to -1 before the addition can bring its value back to 0. That behaviour seems to be benign, but it nevertheless causes test failures in compiler configurations that check for overflow. ``@rustbot`` label +A-code-coverage
Closing this in favour of #125754. |
coverage: Rename MC/DC `conditions_num` to `num_conditions` Updated version of rust-lang#124571, without the other changes that were split out into rust-lang#125108 and rust-lang#125700. This value represents a quantity of conditions, not an ID, so the new spelling is more appropriate. Some of the code touched by this PR could perhaps use some other changes, but I would prefer to keep this PR as a simple renaming and avoid scope creep. `@rustbot` label +A-code-coverage
Rollup merge of rust-lang#125754 - Zalathar:conditions-num, r=lqd coverage: Rename MC/DC `conditions_num` to `num_conditions` Updated version of rust-lang#124571, without the other changes that were split out into rust-lang#125108 and rust-lang#125700. This value represents a quantity of conditions, not an ID, so the new spelling is more appropriate. Some of the code touched by this PR could perhaps use some other changes, but I would prefer to keep this PR as a simple renaming and avoid scope creep. `@rustbot` label +A-code-coverage
This is a combination of two mostly-separate MC/DC coverage cleanups that would conflict with each other, plus some extra tests that appeared along the way.
The first change is to stop recomputing
mcdc_bitmap_bytes
in the query that producesCoverageIdsInfo
. This appears to have been inspired by how we were already computingmax_counter_id
, but there's an important difference between the two cases.When computing
max_counter_id
, the highest counter ID seen might be less than the highest ID used during MIR instrumentation, because some counter-increment statements might have been removed by MIR optimizations.But for the recomputation used for
mcdc_bitmap_bytes
, that's impossible, because both computations are based on pre-optimization info. So there's no need to recompute the exact same value, when it can't have changedThe second change is to rename
conditions_num
tonum_conditions
, to make it clearer that this refers to a number of conditions, not some kind of ID number.Because this change touched the compiler warning for a decision containing too many conditions, I also noticed that we didn't have any tests for that warning.
(It now seems a bit strange to me that this is a compiler warning, not a lint, because it can't be silenced or denied by the usual mechanisms for controlling lints. But I consider that change to be beyond the scope of this PR.)