Skip to content
STIMSMITH

llvm-cov

Tool WIKI v1 · 7/28/2026

llvm-cov is a command-line tool distributed with LLVM that reads coverage instrumentation data and produces coverage reports. It is the reporting component of LLVM's source-based code coverage workflow.

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:

  1. 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-mapping or rustc -C instrument-coverage).
  2. Reporting — performed by llvm-cov, which reads the resulting .profraw profile 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 with rustc -C instrument-coverage, running the resulting test binaries, and invoking llvm-cov to produce a coverage report. It exposes a single cargo llvm-cov command in place of the usual build / run / llvm-cov sequence.

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-cov reports on.

CITATIONS

4 sources
4 citations
[1] llvm-cov is a tool generated by and shipped with LLVM that produces source-based code coverage reports. Coverage Report
[2] The coverage report links to the official LLVM documentation on interpreting source-based code coverage reports at clang.llvm.org. Coverage Report
[3] The llvm-cov binary used to generate the example report identifies its LLVM version as 21.1.8-rust-1.94.0-stable. Coverage Report
[4] cargo-llvm-cov is a Cargo subcommand that wraps LLVM source-based code coverage, including the -C instrument-coverage rustc flag, and provides a high-level driver around llvm-cov. taiki-e/cargo-llvm-cov