3
3
<!-- toc -->
4
4
5
5
` rustc ` supports detailed source-based code and test coverage analysis
6
- with a command line option (` -Z instrument-coverage ` ) that instruments Rust
6
+ with a command line option (` -C instrument-coverage ` ) that instruments Rust
7
7
libraries and binaries with additional instructions and data, at compile time.
8
8
9
9
The coverage instrumentation injects calls to the LLVM intrinsic instruction
@@ -28,16 +28,15 @@ them), and generate various reports for analysis, for example:
28
28
<br />
29
29
30
30
Detailed instructions and examples are documented in the
31
- [ Rust Unstable Book (under
32
- _ compiler-flags/instrument-coverage_ )] [ unstable-book-instrument-coverage ] .
31
+ [ Rustc Book] [ rustc-book-instrument-coverage ] .
33
32
34
33
[ llvm-instrprof-increment ] : https://llvm.org/docs/LangRef.html#llvm-instrprof-increment-intrinsic
35
34
[ coverage map ] : https://llvm.org/docs/CoverageMappingFormat.html
36
- [ unstable -book-instrument-coverage] : https://doc.rust-lang.org/nightly/unstable-book/compiler-flags /instrument-coverage.html
35
+ [ rustc -book-instrument-coverage] : https://doc.rust-lang.org/nightly/rustc /instrument-coverage.html
37
36
38
37
## Rust symbol mangling
39
38
40
- ` -Z instrument-coverage ` automatically enables Rust symbol mangling ` v0 ` (as
39
+ ` -C instrument-coverage ` automatically enables Rust symbol mangling ` v0 ` (as
41
40
if the user specified ` -C symbol-mangling-version=v0 ` option when invoking
42
41
` rustc ` ) to ensure consistent and reversible name mangling. This has two
43
42
important benefits:
@@ -62,7 +61,7 @@ In the `rustc` source tree, `library/profiler_builtins` bundles the LLVM
62
61
` profiler_builtins ` library is only included when ` profiler = true ` is set
63
62
in ` rustc ` 's ` config.toml ` .)
64
63
65
- When compiling with ` -Z instrument-coverage ` ,
64
+ When compiling with ` -C instrument-coverage ` ,
66
65
[ ` CrateLoader::postprocess() ` ] [ crate-loader-postprocess ] dynamically loads the
67
66
` profiler_builtins ` library by calling ` inject_profiler_runtime() ` .
68
67
@@ -287,7 +286,7 @@ instrumented) in the [`coverage`][coverage-test-samples] directory, and the
287
286
actual tests and expected results in [ ` coverage-reports ` ] .
288
287
289
288
Finally, the [ ` coverage-llvmir ` ] test compares compiles a simple Rust program
290
- with ` -Z instrument-coverage ` and compares the compiled program's LLVM IR to
289
+ with ` -C instrument-coverage ` and compares the compiled program's LLVM IR to
291
290
expected LLVM IR instructions and structured data for a coverage-enabled
292
291
program, including various checks for Coverage Map-related metadata and the LLVM
293
292
intrinsic calls to increment the runtime counters.
@@ -424,7 +423,7 @@ theme in your development environment, you will probably want to use this
424
423
option so you can review the graphviz output without straining your vision.
425
424
426
425
``` shell
427
- $ rustc -Z instrument-coverage -Z dump-mir=InstrumentCoverage \
426
+ $ rustc -C instrument-coverage -Z dump-mir=InstrumentCoverage \
428
427
-Z dump-mir-graphviz some_rust_source.rs
429
428
```
430
429
@@ -497,7 +496,7 @@ An visual, interactive representation of the final `CoverageSpan`s can be
497
496
generated with the following ` rustc ` flags:
498
497
499
498
``` shell
500
- $ rustc -Z instrument-coverage -Z dump-mir=InstrumentCoverage \
499
+ $ rustc -C instrument-coverage -Z dump-mir=InstrumentCoverage \
501
500
-Z dump-mir-spanview some_rust_source.rs
502
501
```
503
502
0 commit comments