Skip to content

Commit 2025284

Browse files
authored
Remove outdated references to coverage debug code (rust-lang#1797)
1 parent cb4c521 commit 2025284

File tree

3 files changed

+3
-98
lines changed

3 files changed

+3
-98
lines changed

src/img/coverage-graphviz-01.png

-332 KB
Binary file not shown.

src/img/coverage-spanview-01.png

-313 KB
Binary file not shown.

src/llvm-coverage-instrumentation.md

+3-98
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,14 @@ The `Instrumentor`'s `inject_counters()` uses the `CoverageGraph` to
335335
compute the best places to inject coverage counters, as MIR `Statement`s,
336336
with the following steps:
337337

338-
1. Depending on the debugging configurations in `rustc`'s, `config.toml`,
339-
and `rustc` command line flags, various debugging features may be enabled
340-
to enhance `debug!()` messages in logs, and to generate various "dump" files,
341-
to help developers understand the MIR transformation process for coverage.
342-
Most of the debugging features are implemented in the [`debug`][debug]
343-
sub-module.
344-
2. [`generate_coverage_spans()`][generate-coverage-spans] computes the minimum set of distinct,
338+
1. [`generate_coverage_spans()`][generate-coverage-spans] computes the minimum set of distinct,
345339
non-branching code regions, from the MIR. These `CoverageSpan`s
346340
represent a span of code that must be counted.
347-
3. [`make_bcb_counters()`][make-bcb-counters] generates `CoverageKind::Counter`s and
341+
2. [`make_bcb_counters()`][make-bcb-counters] generates `CoverageKind::Counter`s and
348342
`CoverageKind::Expression`s for each `CoverageSpan`, plus additional
349343
`intermediate_expressions`[^intermediate-expressions], not associated with any `CodeRegion`, but
350344
are required to compute a final `Expression` value for a `CodeRegion`.
351-
4. Inject the new counters into the MIR, as new `StatementKind::Coverage`
345+
3. Inject the new counters into the MIR, as new `StatementKind::Coverage`
352346
statements. This is done by three distinct functions:
353347
- `inject_coverage_span_counters()`
354348
- `inject_indirect_counters()`
@@ -420,66 +414,12 @@ The BCB CFG is critical to simplifying the coverage analysis by ensuring graph p
420414
queries (`is_dominated_by()`, `predecessors`, `successors`, etc.) have branch (control flow)
421415
significance.
422416

423-
To visualize the `CoverageGraph`, you can generate a _graphviz_ `*.dot`
424-
file with the following `rustc` flags:[^graphviz-dark-mode]
425-
426-
[^graphviz-dark-mode]: This image also applies `-Z graphviz-dark-mode`, to
427-
produce a Graphviz document with "dark mode" styling. If you use a dark mode or
428-
theme in your development environment, you will probably want to use this
429-
option so you can review the graphviz output without straining your vision.
430-
431-
```shell
432-
$ rustc -C instrument-coverage -Z dump-mir=InstrumentCoverage \
433-
-Z dump-mir-graphviz some_rust_source.rs
434-
```
435-
436-
The `-Z dump-mir` flag requests [MIR debugging
437-
output][mir-debugging] (generating `*.mir` files, by default).
438-
`-Z dump-mir-graphviz` additionally generates `*.dot` files.
439-
`-Z dump-mir=InstrumentCoverage` restricts these files to the
440-
`InstrumentCoverage` pass. All files are written to the `./mir_dump/`
441-
directory, by default.
442-
443-
Files with names ending in `.-------.InstrumentCoverage.0.dot` contain the
444-
_graphviz_ representations of a `CoverageGraph` (one for each MIR, that is,
445-
for each function and closure):
446-
447-
<img alt="cropped image of a sample CoverageGraph in graphviz format"
448-
src="img/coverage-graphviz-01.png" style="border: 1px solid gray" class="center"/>
449-
<br/>
450-
451-
This image shows each `BasicCoverageBlock` as a rectangular _node_, with
452-
directional edges (the arrows) leading from each node to its `successors()`.
453-
The nodes contain information in sections:
454-
455-
1. The gray header has a label showing the BCB ID (or _index_ for looking up
456-
its `BasicCoverageBlockData`).
457-
2. The first content section shows the assigned `Counter` or `Expression` for
458-
each contiguous section of code. (There may be more than one `Expression`
459-
incremented by the same `Counter` for noncontiguous sections of code
460-
representing the same sequential actions.) Note the code is represented by
461-
the line and column ranges (for example: `52:28-52:33`, representing the
462-
original source line 52, for columns 28-33). These are followed by the MIR
463-
`Statement` or `Terminator` represented by that source range. (How these
464-
coverage regions are determined is discussed in the following section.)
465-
3. The final section(s) show the MIR `BasicBlock`s (by ID/index and its
466-
`TerminatorKind`) contained in this BCB. The last BCB is separated out
467-
because its `successors()` determine the edges leading out of the BCB, and
468-
into the `leading_bb()` (first `BasicBlock`) of each successor BCB.
469-
470-
Note, to find the `BasicCoverageBlock` from a final BCB `Terminator`'s
471-
successor `BasicBlock`, there is an index and helper
472-
function--[`bcb_from_bb()`][bcb-from-bb]--to look up a `BasicCoverageBlock` from
473-
*any* contained `BasicBlock`.
474-
475417
[directed-graph]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/graph/trait.DirectedGraph.html
476418
[graph-traits]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/graph/index.html#traits
477419
[mir-dev-guide]: mir/index.md
478420
[compute-basic-coverage-blocks]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/graph/struct.CoverageGraph.html#method.compute_basic_coverage_blocks
479421
[simplify-cfg]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/simplify/enum.SimplifyCfg.html
480422
[rust-lang/rust#78544]: https://github.com/rust-lang/rust/issues/78544
481-
[mir-debugging]: mir/debugging.md
482-
[bcb-from-bb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/graph/struct.CoverageGraph.html#method.bcb_from_bb
483423

484424
### `CoverageSpans`
485425

@@ -498,32 +438,6 @@ The final stage of `generate_coverage_spans()` is handled by
498438
merges and de-duplicates them, and returns an optimal, minimal set of `CoverageSpan`s
499439
that can be used to assign coverage `Counter`s or `Expression`s, one-for-one.
500440

501-
An visual, interactive representation of the final `CoverageSpan`s can be
502-
generated with the following `rustc` flags:
503-
504-
```shell
505-
$ rustc -C instrument-coverage -Z dump-mir=InstrumentCoverage \
506-
-Z dump-mir-spanview some_rust_source.rs
507-
```
508-
509-
These flags request Spanview output for the `InstrumentCoverage` pass, and the
510-
resulting files (one for each MIR, that is, for each function or closure) can be
511-
found in the `mir_dump` directory (by default), with the extension:
512-
`.-------.InstrumentCoverage.0.html`.
513-
514-
<img alt="cropped image of a sample Spanview in a browser"
515-
src="img/coverage-spanview-01.png" style="border: 1px solid gray" class="center"/>
516-
<br/>
517-
518-
The image above shows one such example. The orange and blue backgrounds
519-
highlight alternating `CoverageSpan`s from the refined set. Hovering over a
520-
line expands the output on that line to show the MIR `BasicBlock` IDs covered
521-
by each `CoverageSpan`. While hovering, the `CoverageSpan` under the pointer
522-
also has a _tooltip_ block of text, showing even more detail, including the
523-
MIR `Statement`s and `Terminator`s contributing to the `CoverageSpan`, and
524-
their individual `Span`s (which should be encapsulated within the code region
525-
of the refined `CoverageSpan`)
526-
527441
[coverage-spans]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/spans/struct.CoverageSpans.html
528442
[coverage-span]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/spans/struct.CoverageSpan.html
529443
[to-refined-spans]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/spans/struct.CoverageSpans.html#method.to_refined_spans
@@ -622,12 +536,3 @@ so the counter is only incremented when traversing the branch edge.
622536
[inject-coverage-span-counters]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/struct.Instrumentor.html#method.inject_coverage_span_counters
623537
[inject-indirect-counters]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/struct.Instrumentor.html#method.inject_indirect_counters
624538
[inject-intermediate-expression]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/fn.inject_intermediate_expression.html
625-
626-
### Additional Debugging Support
627-
628-
See the
629-
[crate documentation for `rustc_mir::transform::coverage::debug`][coverage-debugging]
630-
for a detailed description of the debug output, logging, and configuration options
631-
available to developers working on the `InstrumentCoverage` pass.
632-
633-
[coverage-debugging]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_transform/coverage/debug/index.html

0 commit comments

Comments
 (0)