Commit 4ffb5c5
committed
Auto merge of rust-lang#76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandry
Tools, tests, and experimenting with MIR-derived coverage counters
Leverages the new mir_dump output file in HTML+CSS (from rust-lang#76074) to visualize coverage code regions
and the MIR features that they came from (including overlapping spans).
See example below.
The `run-make-fulldeps/instrument-coverage` test has been refactored to maximize test coverage and reduce code duplication. The new tests support testing with and without `-Clink-dead-code`, so Rust coverage can be tested on MSVC (which, currently, only works with `link-dead-code` _disabled_).
New tests validate coverage region generation and coverage reports with multiple counters per function. Starting with a simple `if-else` branch tests, coverage tests for each additional syntax type can be added by simply dropping in a new Rust sample program.
Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.
The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.
Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.
This PR replaces the bulk of PR rust-lang#75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.
This PR depends on two of those other PRs: rust-lang#76002, rust-lang#76003 and rust-lang#76074
Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: rust-lang#34701 - Implement support for LLVMs code coverage
instrumentation

r? @tmandry
FYI: @wesleywiserFile tree
28 files changed
+2072
-299
lines changed- compiler
- rustc_middle/src/mir
- rustc_mir/src/transform
- rustc_session/src
- src/test
- mir-opt
- run-make-fulldeps
- instrument-coverage-cov-reports-base
- instrument-coverage-cov-reports-link-dead-code
- instrument-coverage-llvm-ir-base
- instrument-coverage-llvm-ir-link-dead-code
- instrument-coverage-mir-cov-html-base
- expected_mir_dump.coverage_of_if_else
- instrument-coverage-mir-cov-html-link-dead-code
- expected_mir_dump.coverage_of_if_else
- instrument-coverage
28 files changed
+2072
-299
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1530 | 1530 | | |
1531 | 1531 | | |
1532 | 1532 | | |
1533 | | - | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
1534 | 1551 | | |
1535 | 1552 | | |
1536 | 1553 | | |
| |||
0 commit comments