Skip to content
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: Use a query to identify which counter/expression IDs are used #133446

Merged
merged 5 commits into from
Dec 2, 2024

Conversation

Zalathar
Copy link
Contributor

Given that we already have a query to identify the highest-numbered counter ID in a MIR body, we can extend that query to also build bitsets of used counter/expression IDs. That lets us avoid some messy coverage bookkeeping during the main MIR traversal for codegen.

This does mean that we fail to treat some IDs as used in certain MIR-inlining scenarios, but I think that's fine, because it means that the results will be consistent across all instantiations of a function.


There's some more cleanup I want to do in the function coverage collector, since it isn't really collecting anything any more, but I'll leave that for future work.

@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Nov 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2024

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

drop(coverage_map);
let cond_bitmap = bx.coverage_cx()
.try_get_mcdc_condition_bitmap(&instance, decision_depth)
.expect("mcdc cond bitmap should have been allocated for merging into the global bitmap");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this long string causes rustfmt to completely give up on the enclosing statement, so I've split it up to work around that.

@bors
Copy link
Contributor

bors commented Nov 28, 2024

☔ The latest upstream changes (presumably #133551) made this pull request unmergeable. Please resolve the merge conflicts.

@Zalathar
Copy link
Contributor Author

Rebased due to import conflicts; no changes.

@fee1-dead
Copy link
Member

not familiar with coverage, sorry

r? compiler

@rustbot rustbot assigned Nadrieril and unassigned fee1-dead Nov 28, 2024
@Nadrieril
Copy link
Member

not familiar with coverage either, sorry

r? compiler

@rustbot rustbot assigned nnethercote and unassigned Nadrieril Nov 28, 2024
@cjgillot cjgillot self-assigned this Nov 29, 2024
@bors
Copy link
Contributor

bors commented Nov 29, 2024

☔ The latest upstream changes (presumably #133608) made this pull request unmergeable. Please resolve the merge conflicts.

This context is stored in `CodegenCx`, which makes it per-CGU rather than
per-crate. A single crate can have multiple CGUs.
There is unlikely to be any practical difference between a counter limit of
2^32 and a counter limit of (2^32 - 256).
This is currently handled automatically by the fact that codegen doesn't visit
coverage statements in unused functions, but that will no longer be the case
when unused IDs are identified by a separate query instead.
@Zalathar
Copy link
Contributor Author

Rebased again; no changes.

@cjgillot
Copy link
Contributor

cjgillot commented Dec 1, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 1, 2024

📌 Commit 6fc0fe7 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 2, 2024
Rollup of 5 pull requests

Successful merges:

 - rust-lang#131416 (Mark `slice::copy_from_slice` unstably const)
 - rust-lang#131784 (Stabilize unsigned and float variants of `num_midpoint` feature)
 - rust-lang#133446 (coverage: Use a query to identify which counter/expression IDs are used)
 - rust-lang#133711 (add isatty doc alias for `is_terminal`)
 - rust-lang#133712 (rust_analyzer_settings: force use of 'nightly' toolchain)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fa2edee into rust-lang:master Dec 2, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 2, 2024
Rollup merge of rust-lang#133446 - Zalathar:querify, r=cjgillot

coverage: Use a query to identify which counter/expression IDs are used

Given that we already have a query to identify the highest-numbered counter ID in a MIR body, we can extend that query to also build bitsets of used counter/expression IDs. That lets us avoid some messy coverage bookkeeping during the main MIR traversal for codegen.

This does mean that we fail to treat some IDs as used in certain MIR-inlining scenarios, but I think that's fine, because it means that the results will be consistent across all instantiations of a function.

---

There's some more cleanup I want to do in the function coverage collector, since it isn't really collecting anything any more, but I'll leave that for future work.
@Zalathar Zalathar deleted the querify branch December 2, 2024 11:41
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2024
coverage: Use a query to find counters/expressions that must be zero

As of rust-lang#133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well.

There should be no change in compiler output.
fmease added a commit to fmease/rust that referenced this pull request Dec 9, 2024
coverage: Use a query to find counters/expressions that must be zero

As of rust-lang#133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well.

There should be no change in compiler output.
fmease added a commit to fmease/rust that referenced this pull request Dec 9, 2024
coverage: Use a query to find counters/expressions that must be zero

As of rust-lang#133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well.

There should be no change in compiler output.
fmease added a commit to fmease/rust that referenced this pull request Dec 10, 2024
coverage: Use a query to find counters/expressions that must be zero

As of rust-lang#133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well.

There should be no change in compiler output.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 10, 2024
Rollup merge of rust-lang#134029 - Zalathar:zero, r=oli-obk

coverage: Use a query to find counters/expressions that must be zero

As of rust-lang#133446, this query (`coverage_ids_info`) determines which counter/expression IDs are unused. So with only a little extra work, we can take the code that was using that information to determine which coverage counters/expressions must be zero, and move that inside the query as well.

There should be no change in compiler output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants