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: Prepare for improved branch coverage #124217

Merged
merged 8 commits into from Apr 23, 2024
Merged

Conversation

Zalathar
Copy link
Contributor

When trying to rebase my new branch coverage work (including #124154) on top of the introduction of MC/DC coverage (#123409), I found it a lot harder than anticipated. With the benefit of hindsight, the branch coverage code and MC/DC code have become more interdependent than I'm happy with.

This PR therefore disentangles them a bit, so that it will be easier for both areas of code to evolve independently without interference.


This PR also includes a few extra branch coverage tests that I had sitting around from my current branch coverage work. They mostly just demonstrate that certain language constructs listed in #124118 currently don't have branch coverage support.

@rustbot label +A-code-coverage

@rustbot
Copy link
Collaborator

rustbot commented Apr 21, 2024

r? @estebank

rustbot has assigned @estebank.
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 Apr 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 21, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Apr 21, 2024
Comment on lines +119 to +121
for branch in &mut self.mcdc_branch_spans[rebase_idx..] {
branch.condition_info = None;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the MC/DC code gives up on full MC/DC instrumentation, instead of creating a BranchSpan, it now creates an MCDCBranchSpan with condition_info: None.

That span will eventually get turned back into an ordinary branch region, in the coverage MIR pass. This change will let me improve how ordinary branch coverage is handled during MIR building, without having to also worry about how it interacts with MC/DC.

@Zalathar
Copy link
Contributor Author

cc @Lambdaris @ZhuUx @RenjiSann

This will affect any work that you're building on top of the current MC/DC code.

@rust-log-analyzer

This comment has been minimized.

@Zalathar Zalathar force-pushed the pre-branch branch 2 times, most recently from 3a6c74b to c6eb1ac Compare April 21, 2024 04:49
@Lambdaris
Copy link

Lambdaris commented Apr 21, 2024

The separation might mean it's better for mcdc to develop its own methods to deal with pattern match like match and if let and might lead to disagreement in branch coverage results (LLVM also generates branch coverage reports for mcdc branch). This would be acceptable in development. Let's consider whether they can be integrated when they are both well-developed.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 22, 2024

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned estebank Apr 22, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Apr 22, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 22, 2024

📌 Commit 2b6adb0 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 Apr 22, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 22, 2024
coverage: Prepare for improved branch coverage

When trying to rebase my new branch coverage work (including rust-lang#124154) on top of the introduction of MC/DC coverage (rust-lang#123409), I found it a lot harder than anticipated. With the benefit of hindsight, the branch coverage code and MC/DC code have become more interdependent than I'm happy with.

This PR therefore disentangles them a bit, so that it will be easier for both areas of code to evolve independently without interference.

---

This PR also includes a few extra branch coverage tests that I had sitting around from my current branch coverage work. They mostly just demonstrate that certain language constructs listed in rust-lang#124118 currently don't have branch coverage support.

`@rustbot` label +A-code-coverage
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2024
…llaumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#124178 ([cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times)
 - rust-lang#124183 (Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref)
 - rust-lang#124217 (coverage: Prepare for improved branch coverage)
 - rust-lang#124220 (Miri: detect wrong vtables in wide pointers)
 - rust-lang#124252 (Improve ICE message for forbidden dep-graph reads.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2024
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#115913 (checked_ilog: improve performance)
 - rust-lang#124178 ([cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times)
 - rust-lang#124183 (Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref)
 - rust-lang#124217 (coverage: Prepare for improved branch coverage)
 - rust-lang#124230 (Stabilize generic `NonZero`.)
 - rust-lang#124252 (Improve ICE message for forbidden dep-graph reads.)
 - rust-lang#124268 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2024
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#115913 (checked_ilog: improve performance)
 - rust-lang#124178 ([cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times)
 - rust-lang#124183 (Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref)
 - rust-lang#124217 (coverage: Prepare for improved branch coverage)
 - rust-lang#124230 (Stabilize generic `NonZero`.)
 - rust-lang#124252 (Improve ICE message for forbidden dep-graph reads.)
 - rust-lang#124268 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 17c2879 into rust-lang:master Apr 23, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2024
Rollup merge of rust-lang#124217 - Zalathar:pre-branch, r=oli-obk

coverage: Prepare for improved branch coverage

When trying to rebase my new branch coverage work (including rust-lang#124154) on top of the introduction of MC/DC coverage (rust-lang#123409), I found it a lot harder than anticipated. With the benefit of hindsight, the branch coverage code and MC/DC code have become more interdependent than I'm happy with.

This PR therefore disentangles them a bit, so that it will be easier for both areas of code to evolve independently without interference.

---

This PR also includes a few extra branch coverage tests that I had sitting around from my current branch coverage work. They mostly just demonstrate that certain language constructs listed in rust-lang#124118 currently don't have branch coverage support.

``@rustbot`` label +A-code-coverage
@Zalathar Zalathar deleted the pre-branch branch April 23, 2024 03:03
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2024
Split mcdc code to a sub module of coverageinfo

A further work from rust-lang#124217 . I have made relatively large changes when working on rust-lang#124278 so that it would better split them from `coverageinfo.rs` to avoid potential troubling merge work with improved branch coverage by `@Zalathar` .

Besides `BlockMarkerGenerator` is added to avoid ownership problems (mostly needed for following change of rust-lang#124278 )

All code changes are done in [a37d737a](rust-lang@a3d737a) while the second commit just renames the file.

cc `@RenjiSann` `@Zalathar`
This will impact your current work.
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.

None yet

7 participants