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: Replace the old span refiner with a single function #126294

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Jun 12, 2024

As more and more of the span refiner's functionality has been pulled out into separate early passes, it has finally reached the point where we can remove the rest of the old SpansRefiner code, and replace it with a single modestly-sized function.

There should be no change to the resulting coverage mappings, as demonstrated by the lack of changes to test output.

There is almost no change to the resulting coverage mappings. There are some minor changes to loop that on inspection appear to be neutral in terms of accuracy, with the old behaviour being a slightly-horrifying implementation detail of the old code, so I think they're acceptable.

Previous work in this direction includes:

@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2024

r? @oli-obk

rustbot has assigned @oli-obk.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 12, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 12, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Jun 12, 2024
@rust-log-analyzer

This comment has been minimized.

@Zalathar Zalathar force-pushed the spans-refiner branch 2 times, most recently from ac4aa2e to 0b4778e Compare June 12, 2024 03:12
@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Contributor Author

Oh, looks like there was a change in mappings, but it was only hit by one of the mir-opt tests. I’ll have to look into it.

@Zalathar
Copy link
Contributor Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 12, 2024
This test extracts a fragment of `issue-84561.rs` that has historically proven
troublesome when trying to modify how spans are extracted from MIR.
This is a modified copy of `tests/mir-opt/coverage/instrument_coverage.rs`.
As more and more of the span refiner's functionality has been pulled out into
separate early passes, it has finally reached the point where we can remove the
rest of the old `SpansRefiner` code, and replace it with a single
modestly-sized function.
@Zalathar
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 12, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Jun 12, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jun 12, 2024

📌 Commit 2fa78f3 has been approved by oli-obk

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 Jun 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 12, 2024
…llaumeGomez

Rollup of 9 pull requests

Successful merges:

 - rust-lang#126039 (Promote `arm64ec-pc-windows-msvc` to tier 2)
 - rust-lang#126075 (Remove `DebugWithInfcx` machinery)
 - rust-lang#126228 (Provide correct parent for nested anon const)
 - rust-lang#126232 (interpret: dyn trait metadata check: equate traits in a proper way)
 - rust-lang#126242 (Simplify provider api to improve llvm ir)
 - rust-lang#126294 (coverage: Replace the old span refiner with a single function)
 - rust-lang#126295 (No uninitalized report in a pre-returned match arm)
 - rust-lang#126312 (Update `rustc-perf` submodule)
 - rust-lang#126322 (Follow up to splitting core's PanicInfo and std's PanicInfo)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7a4f55b into rust-lang:master Jun 12, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 12, 2024
Rollup merge of rust-lang#126294 - Zalathar:spans-refiner, r=oli-obk

coverage: Replace the old span refiner with a single function

As more and more of the span refiner's functionality has been pulled out into separate early passes, it has finally reached the point where we can remove the rest of the old `SpansRefiner` code, and replace it with a single modestly-sized function.

~~There should be no change to the resulting coverage mappings, as demonstrated by the lack of changes to test output.~~

There is *almost* no change to the resulting coverage mappings. There are some minor changes to `loop` that on inspection appear to be neutral in terms of accuracy, with the old behaviour being a slightly-horrifying implementation detail of the old code, so I think they're acceptable.

Previous work in this direction includes:
- rust-lang#125921
- rust-lang#121019
- rust-lang#119208
@Zalathar Zalathar deleted the spans-refiner branch June 12, 2024 23:47
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jun 17, 2024
coverage: Arrange span extraction/refinement as a series of passes

The old code for extracting/refining coverage spans from MIR has been dismantled and split up into several passes (e.g. see rust-lang#126294), but because this was done incrementally, the resulting code is disorganised.

This PR addresses that by moving the main control-flow into a single function (`coverage::spans::extract_refined_covspans`) that more clearly shows the process as a series of separate steps, most delegated to helper functions in the same file.

This should make it easier to understand and modify the refinement process. It also means that submodule `from_mir` is now only concerned with the details of extracting relevant spans from the various kinds of MIR statement/terminator.

There should be no change to the resulting coverage maps, as demonstrated by the lack of changes to tests.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 17, 2024
Rollup merge of rust-lang#126535 - Zalathar:covspans, r=nnethercote

coverage: Arrange span extraction/refinement as a series of passes

The old code for extracting/refining coverage spans from MIR has been dismantled and split up into several passes (e.g. see rust-lang#126294), but because this was done incrementally, the resulting code is disorganised.

This PR addresses that by moving the main control-flow into a single function (`coverage::spans::extract_refined_covspans`) that more clearly shows the process as a series of separate steps, most delegated to helper functions in the same file.

This should make it easier to understand and modify the refinement process. It also means that submodule `from_mir` is now only concerned with the details of extracting relevant spans from the various kinds of MIR statement/terminator.

There should be no change to the resulting coverage maps, as demonstrated by the lack of changes to tests.
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.

5 participants