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: Clarify some parts of coverage counter creation #130380

Merged
merged 7 commits into from
Sep 17, 2024

Conversation

Zalathar
Copy link
Contributor

This is a series of semi-related changes that are trying to make the counters module easier to read, understand, and modify.

For example, the existing code happens to avoid ever using the count for a TerminatorKind::Yield node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures.

This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read.

There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.

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

rustbot commented Sep 15, 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
Copy link
Collaborator

rustbot commented Sep 15, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Sep 15, 2024
- Look up the node's predecessors only once
- Get rid of some overly verbose logging
- Explain why some nodes need physical counters
- Extract a helper method to create and set a physical node counter
By building the list of candidate edges up-front, and making the
candidate-selection method fallible, we can remove a few pieces of awkward
code.
This does a better job of expressing the special cases that occur when a node
in the coverage graph has exactly one in-edge.
Given that we directly access the graph predecessors/successors in so many
other places, and sometimes must do so to satisfy the borrow checker, there is
little value in having this trivial helper method.
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, AFAICT the changes look reasonable and does simplify the implementation quite a bit. Please feel free to r=me unless you specifically want someone else to look at this.

@jieyouxu jieyouxu assigned jieyouxu and unassigned fee1-dead Sep 16, 2024
@Zalathar
Copy link
Contributor Author

Thanks.

@bors r=jieyouxu

@bors
Copy link
Contributor

bors commented Sep 16, 2024

📌 Commit 2a3e17c has been approved by jieyouxu

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 Sep 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2024
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#130380 (coverage: Clarify some parts of coverage counter creation)
 - rust-lang#130427 (run_make_support: rectify symlink handling)
 - rust-lang#130447 (rustc_llvm: update for llvm/llvm-project@2ae968a0d9fb61606b020e898d88…)
 - rust-lang#130448 (fix: Remove duplicate `LazyLock` example.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1a7fdc7 into rust-lang:master Sep 17, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 17, 2024
Rollup merge of rust-lang#130380 - Zalathar:counters, r=jieyouxu

coverage: Clarify some parts of coverage counter creation

This is a series of semi-related changes that are trying to make the `counters` module easier to read, understand, and modify.

For example, the existing code happens to avoid ever using the count for a `TerminatorKind::Yield` node as the count for its sole out-edge (since doing so would be incorrect), but doesn't do so explicitly, so seemingly-innocent changes can result in baffling test failures.

This PR also takes the opportunity to simplify some debug-logging code that was making its surrounding code disproportionately hard to read.

There should be no changes to the resulting coverage instrumentation/mappings, as demonstrated by the absence of changes to the coverage test suite.
@Zalathar Zalathar deleted the counters branch September 17, 2024 06:39
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 22, 2024
coverage: Make counter creation handle node/edge counters more uniformly

Similar to rust-lang#130380, this is another round of small improvements informed by my ongoing attempts to overhaul coverage counter creation.

One of the big benefits is getting rid of the awkward special-case that would sometimes attach an edge counter to a node instead. That was needed by the code that chooses which out-edge should be given a counter expression, but we can avoid that by making the corresponding check a little smarter.

I've also renamed several things to be simpler and more consistent, which should help with future changes.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2024
Rollup merge of rust-lang#131918 - Zalathar:counters, r=nnethercote

coverage: Make counter creation handle node/edge counters more uniformly

Similar to rust-lang#130380, this is another round of small improvements informed by my ongoing attempts to overhaul coverage counter creation.

One of the big benefits is getting rid of the awkward special-case that would sometimes attach an edge counter to a node instead. That was needed by the code that chooses which out-edge should be given a counter expression, but we can avoid that by making the corresponding check a little smarter.

I've also renamed several things to be simpler and more consistent, which should help with future changes.
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.

6 participants