llvm-cov
Overview
llvm-cov is a command-line utility shipped with LLVM that converts raw profile data produced by LLVM's instrumentation-based coverage passes into human-readable coverage reports (text, HTML, and JSON formats). It works in conjunction with the instrumentation emitted by compilers such as clang and rustc when source-based code coverage is enabled.
Role in the source-based code coverage workflow
LLVM's source-based code coverage consists of two cooperating components:
- Instrumentation — performed at compile time by the compiler front end / LLVM IR passes when the appropriate coverage mapping option is supplied (for example,
clang -fprofile-instr-generate -fcoverage-mappingorrustc -C instrument-coverage). - Reporting — performed by
llvm-cov, which reads the resulting.profrawprofile data together with the embedded coverage mapping and renders a coverage report.
llvm-cov implements the report-generation half of this pipeline and is therefore the user-facing tool most developers invoke after running their instrumented binaries.
Invocation and output
llvm-cov accepts a coverage mapping (typically embedded in the instrumented binary) and one or more raw profile files, and produces reports describing line, region, and branch coverage. The default text format includes per-file coverage summaries as well as a legend explaining the columns, and links to upstream documentation describing how to interpret the report.
HTML and JSON output modes are also available, enabling integration with external tools and dashboards.
Versioning
llvm-cov is shipped as part of LLVM releases and is also embedded in the toolchains distributed with other projects. For example, coverage reports generated by Rust's source-based code coverage workflow are emitted by the llvm-cov binary shipped with the Rust toolchain (the version string identifies the LLVM and Rust releases that provided the binary).
Ecosystem tooling
Several community tools wrap llvm-cov to simplify common workflows:
cargo-llvm-cov— a Cargo subcommand that orchestrates building a Rust crate withrustc -C instrument-coverage, running the resulting test binaries, and invokingllvm-covto produce a coverage report. It exposes a singlecargo llvm-covcommand in place of the usual build / run /llvm-covsequence.
Interpreting reports
The text and HTML reports generated by llvm-cov use a common visual convention (coverage markers on each source line plus summary statistics). The official documentation linked from the tool's output describes how to interpret these markers.
See also
- LLVM — the umbrella project that distributes
llvm-cov. - Source-Based Code Coverage — the technique that
llvm-covreports on.