You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add conditional support for coverage map version 6
This commit augments Swatinem's initial commit in uncommitted PR #90047,
which was a great starting point, but did not fully support LLVM
Coverage Mapping Format version 6.
Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.
Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.
This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Copy file name to clipboardExpand all lines: compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
+33-12
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
9
9
use rustc_hir::def_id::{DefId,DefIdSet};
10
10
use rustc_llvm::RustString;
11
11
use rustc_middle::mir::coverage::CodeRegion;
12
+
use rustc_middle::ty::TyCtxt;
12
13
use rustc_span::Symbol;
13
14
14
15
use std::ffi::CString;
@@ -17,9 +18,10 @@ use tracing::debug;
17
18
18
19
/// Generates and exports the Coverage Map.
19
20
///
20
-
/// This Coverage Map complies with Coverage Mapping Format version 5 (zero-based encoded as 4),
21
-
/// as defined at [LLVM Code Coverage Mapping Format](https://github.com/rust-lang/llvm-project/blob/rustc/13.0-2021-09-30/llvm/docs/CoverageMappingFormat.rst#llvm-code-coverage-mapping-format).
22
-
/// This version is supported by the LLVM coverage tools (`llvm-profdata` and `llvm-cov`)
Copy file name to clipboardExpand all lines: src/doc/unstable-book/src/compiler-flags/instrument-coverage.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ This document describes how to enable and use the LLVM instrumentation-based cov
20
20
When `-Z instrument-coverage` is enabled, the Rust compiler enhances rust-based libraries and binaries by:
21
21
22
22
- Automatically injecting calls to an LLVM intrinsic ([`llvm.instrprof.increment`]), at functions and branches in compiled code, to increment counters when conditional sections of code are executed.
23
-
- Embedding additional information in the data section of each library and binary (using the [LLVM Code Coverage Mapping Format]_Version 5_, supported _only_ in LLVM 12 and up), to define the code regions (start and end positions in the source code) being counted.
23
+
- Embedding additional information in the data section of each library and binary (using the [LLVM Code Coverage Mapping Format]_Version 5_, if compiling with LLVM 12, or _Version 6_, if compiling with LLVM 13 or higher), to define the code regions (start and end positions in the source code) being counted.
24
24
25
25
When running a coverage-instrumented program, the counter values are written to a `profraw` file at program termination. LLVM bundles tools that read the counter results, combine those results with the coverage map (embedded in the program binary), and generate coverage reports in multiple formats.
0 commit comments