LLVM-COV(1)
okay so bestie, welcome to LLVM-COV(1), aka the llvm-cov manual from the LLVM crew β and she is literally all about emitting coverage information π
β¨
πΈ NAME πΈ
llvm-cov - emit coverage information
β SYNOPSIS β
llvm-cov command [args...]
π DESCRIPTION π
The llvm-cov tool shows code coverage information for programs that are instrumented to emit profile data. It can be used to work with gcov-style coverage or with clang's instrumentation based profiling. Lowkey a dual-threat icon.
If the program is invoked with a base name of gcov, it will behave as if the llvm-cov gcov command were called. Otherwise, a command should be provided. So yeah, give her a command unless you're coming in through the gcov side door. iykyk.
π COMMANDS π
the command lineup is giving main character energy:
gcovshowreportexport
π§ GCOV COMMAND π§
π¦ SYNOPSIS π¦
llvm-cov gcov [options] SOURCEFILE
πΊ DESCRIPTION πΊ
The llvm-cov gcov tool reads code coverage data files and displays the coverage information for a specified source file. It is compatible with the gcov tool from version 4.2 of GCC and may also be compatible with some later versions of gcov. Ngl, that compatibility is lowkey iconic.
To use llvm-cov gcov, you must first build an instrumented version of your application that collects coverage data as it runs. Compile with the -fprofile-arcs and -ftest-coverage options to add the instrumentation. (Alternatively, you can use the --coverage option, which includes both of those other options.) So bestie, coverage sauce goes in at compile time, not after.
At the time you compile the instrumented code, a .gcno data file will be generated for each object file. These .gcno files contain half of the coverage data. The other half of the data comes from .gcda files that are generated when you run the instrumented program, with a separate .gcda file for each object file. It's giving split custody of the coverage data, honestly.
Each time you run the program, the execution counts are summed into any existing .gcda files, so be sure to remove any old files if you do not want their contents to be included.
β οΈ bestie warning: them old .gcda files will keep stacking counts, so delete them if you don't want their contents to be included.
By default, the .gcda files are written into the same directory as the object files, but you can override that by setting the GCOV_PREFIX and GCOV_PREFIX_STRIP environment variables. The GCOV_PREFIX_STRIP variable specifies a number of directory components to be removed from the start of the absolute path to the object file directory. After stripping those directories, the prefix from the GCOV_PREFIX variable is added. cute, right?
These environment variables allow you to run the instrumented program on a machine where the original object file directories are not accessible, but you will then need to copy the .gcda files back to the object file directories where llvm-cov gcov expects to find them. So yes, portable queen, but you gotta bring the data home π«Ά.
Once you have generated the coverage data files, run llvm-cov gcov for each main source file where you want to examine the coverage results. This should be run from the same directory where you previously ran the compiler. The results for the specified source file are written to a file named by appending a .gcov suffix. A separate output file is also created for each file included by the main source file, also with a .gcov suffix added. One source file in, a whole little .gcov family out. Not me being obsessed with the file suffixes.
The basic content of an .gcov output file is a copy of the source file with an execution count and line number prepended to every line. The execution count is shown as - if a line does not contain any executable code. If a line contains code but that code was never executed, the count is displayed as #####. So - means "no executable code here" and ##### means "code was here but nobody ran it" β periodt.
π OPTIONS π
okay, vibe check time: here's every option, and we are not skipping a single one.
-a,--all-blocksβ Display all basic blocks. If there are multiple blocks for a single line of source code, this option causesllvm-covto show the count for each block instead of just one count for the entire line. Like, every block gets its moment, no blocking the block counts π .-b,--branch-probabilitiesβ Display conditional branch probabilities and a summary of branch information. Branch data, slay.-c,--branch-countsβ Display branch counts instead of probabilities (requires-b). Yes,-bis mandatory, bestie.-m,--demangled-namesβ Demangle function names. Because readable names > cursed symbols.-f,--function-summariesβ Show a summary of coverage for each function instead of just one summary for an entire source file. Per-function receipts, fr fr.--helpβ Display available options (--help-hiddenfor more). The hidden options are giving secret menu energy.-l,--long-file-namesβ For coverage output of files included from the main source file, add the main file name followed by##as a prefix to the output file names. This can be combined with the--preserve-pathsoption to use complete paths for both the main file and the included file.-n,--no-outputβ Do not output any.gcovfiles. Summary information is still displayed. So you get the tea, just not the files.-o <DIR|FILE>,--object-directory=<DIR>,--object-file=<FILE>β Find objects inDIRor based onFILE's path. If you specify a particular object file, the coverage data files are expected to have the same base name with.gcnoand.gcdaextensions. If you specify a directory, the files are expected in that directory with the same base name as the source file.-p,--preserve-pathsβ Preserve path components when naming the coverage output files. In addition to the source file name, include the directories from the path to that file. The directories are separate by#characters, with.directories removed and..directories replaced by^characters. When used with the--long-file-namesoption, this applies to both the main file name and the included file name.-rβ Only dump files with relative paths or absolute paths with the prefix specified by-s. Picky in a very specific way, and honestly valid.-s <string>β Source prefix to elide. Short and mysterious, just like the option says.-t,--stdoutβ Print to stdout instead of producing.gcovfiles. Terminal girlies, this one's for you.-u,--unconditional-branchesβ Include unconditional branches in the output for the--branch-probabilitiesoption. Unconditional branches deserve screen time too.-versionβ Display the version ofllvm-cov. One dash, bestie, don't add a second one.-x,--hash-filenamesβ Use md5 hash of file name when naming the coverage output files. The source file name will be suffixed by##followed by MD5 hash calculated for it.
π EXIT STATUS π
llvm-cov gcov returns 1 if it cannot read input files. Otherwise, it exits with zero. That's the whole exit-status story, and she ate.
π¦ SHOW COMMAND π¦
πΈ SYNOPSIS πΈ
llvm-cov show [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π DESCRIPTION π
Okay so bestie, llvm-cov show is the one that gives you line-by-line coverage for the binaries in BIN..., using the profile data in PROFILE. You can optionally filter it so it only shows coverage for the files you list in SOURCE.... Cute, focused, slay.
BIN can be an executable, an object file, a dynamic library, or an archive β thin or otherwise. No cap.
To use llvm-cov show, you need a program compiled with instrumentation that emits profile and coverage data. With clang, build it using the -fprofile-instr-generate and -fcoverage-mapping flags. If youβre linking with the clang driver, pass -fprofile-instr-generate to the link stage too, so the necessary runtime libraries get linked in. Do not skip that part, bestie, the runtime libs are lowkey essential.
The coverage info is stored inside the built executable or library itself β thatβs the thing you pass to llvm-cov show as a BIN argument. The profile data gets generated by running this instrumented program normally. When the program exits, it writes out a raw profile file, typically called default.profraw, and you can convert that into something suitable for the PROFILE argument using the llvm-profdata merge tool. Iconic pipeline behavior.
β¨ OPTIONS β¨
-show-branches=<VIEW>β shows coverage for branch conditions, either as a count or as a percentage. The supported views are"count"and"percent".-show-mcdcβ shows modified condition/decision coverage (MC/DC) for each applicable boolean expression.-show-mcdc-non-executed-vectorsβ when showing MC/DC details, also lists test vectors that were not executed (like in aNot executedsection after the executed vectors). By default, only executed test vectors are shown.-show-line-countsβ shows execution counts for each line. Defaults to true, unless another-showoption is used.-show-expansionsβ expands inclusions, such as preprocessor macros or textual inclusions, inline in the display of the source file. Defaults to false.-show-instantiationsβ for source regions that are instantiated multiple times, like C++ templates, shows each instantiation separately as well as the combined summary. Defaults to true.-show-regionsβ shows execution counts for each region by displaying a caret that points to the character where the region starts. Defaults to false.-show-line-counts-or-regionsβ shows execution counts for each line if thereβs only one region on the line, but shows the individual regions if there are multiple regions on the line. Defaults to false.-show-directory-coverageβ generates an index file in each directory that contains at least one source file, with a top-level index showing aggregates. Defaults to false.-use-colorβ enables or disables color output. By default this is autodetected.-arch=[*NAMES*]β specifies a list of architectures such that the Nth entry in the list corresponds to the Nth specified binary. If the covered object is a universal binary, this specifies the architecture to use. It is an error to specify an architecture that is not included in the universal binary, or to use an architecture that does not match a non-universal binary.-name=<NAME>β shows code coverage only for functions with the given name.-name-allowlist=<FILE>β shows code coverage only for functions listed in the given file. Each line in the file should start withallowlist_fun:, immediately followed by the name of the function to accept. This name can be a wildcard expression.-name-regex=<PATTERN>β shows code coverage only for functions that match the given regular expression.-ignore-filename-regex=<PATTERN>β skips source code files with file paths that match the given regular expression.-include-filename-regex=<PATTERN>β only includes source code files with file paths that match the given regular expression.-format=<FORMAT>β uses the specified output format. The supported formats are"text"and"html".-tab-size=<TABSIZE>β replaces tabs with<TABSIZE>spaces when preparing reports. Currently, this is only supported for thehtmlformat.-output-dir=PATHβ specifies a directory to write coverage reports into. If the directory does not exist, it is created. When used in function view mode (i.e. when-nameor-name-regexare used to select specific functions), the report is written toPATH/functions.EXTENSION. When used in file view mode, a report for each file is written toPATH/REL_PATH_TO_FILE.EXTENSION.-Xdemangler=<TOOL>|<TOOL-OPTION>β specifies a symbol demangler. This can make reports more human-readable. This option can be specified multiple times to supply arguments to the demangler (e.g.-Xdemangler c++filt -Xdemangler -nfor C++). The demangler is expected to read a newline-separated list of symbols from stdin and write a newline-separated list of the same length to stdout.-num-threads=N,-j=Nβ usesNthreads to write file reports (only applicable when-output-diris specified). WhenN=0,llvm-covauto-detects an appropriate number of threads to use. This is the default.-compilation-dir=<dir>β directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir.-line-coverage-gt=<N>β shows code coverage only for functions with line coverage greater than the given threshold.-line-coverage-lt=<N>β shows code coverage only for functions with line coverage less than the given threshold.-region-coverage-gt=<N>β shows code coverage only for functions with region coverage greater than the given threshold.-region-coverage-lt=<N>β shows code coverage only for functions with region coverage less than the given threshold.-path-equivalence=<from>,<to>β maps the paths in the coverage data to local source file paths. This lets you generate coverage data on one machine, then usellvm-covon a different machine where you have the same files on a different path. Multiple-path-equivalencearguments can be passed to specify different mappings. Each argument consists of a source path<from>and its corresponding local path<to>. The mappings are applied in the order they are specified. If multiple mappings can be applied to a single path, the first mapping encountered is used.-coverage-watermark=<high>,<low>β sets high and low watermarks for coverage inhtmlformat output. This lets you set the high and low watermark of coverage as desired: green when coverage is>= high, red when coverage is< low, and yellow otherwise. Both high and low should be between0-100andhigh > low.-debuginfodβ uses debuginfod to look up coverage mapping for binary IDs present in the profile but not in any object given on the command line. Defaults to true if debuginfod is compiled in and configured via theDEBUGINFOD_URLSenvironment variable.-debug-file-directory=<dir>β provides local directories to search for objects corresponding to binary IDs in the profile (as with debuginfod). Defaults to system build ID directories.-check-binary-idsβ fails if an object file cannot be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup.-empty-profileβ displays the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profile.
π₯ REPORT COMMAND π₯
SYNOPSIS
llvm-cov report [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
DESCRIPTION
okay so llvm-cov report gives you the summary tea on coverage for the binaries BIN... using the profile data PROFILE. It can optionally be filtered to only show coverage for the files listed in SOURCE... bestie, it's giving β¨customizedβ¨.
BIN can be an executable, object file, dynamic library, or archive (thin or otherwise) β like, any of them, it's flexible π .
If no source files are provided, a summary line is printed for each file in the coverage data. If any files are provided, summaries can be shown for each function in the listed files if the -show-functions option is enabled β so remember to turn that on if you want the per-function deets π.
For information on compiling programs for coverage and generating profile data, see SHOW COMMAND π«Ά.
OPTIONS β¨
-use-color[=VALUE]β turn color output on or off. By default this is autodetected, so it usually just knows π.-arch=<name>β if the covered binary is a universal binary, pick which architecture to use. It is an error to specify an architecture that is not included in the universal binary, or to use an architecture that does not match a non-universal binary. So like, don't do that π.-show-region-summaryβ show statistics for all regions. Defaults totrue.-show-branch-summaryβ show statistics for all branch conditions. Defaults totrue.-show-mcdc-summaryβ show MC/DC statistics. Defaults tofalse.-show-functionsβ show coverage summaries for each function. Defaults tofalse.-show-instantiation-summaryβ show statistics for all function instantiations. Defaults tofalse.-ignore-filename-regex=<PATTERN>β skip source code files with file paths that match the given regular expression. Bye bye noise π.-compilation-dir=<dir>β directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir. iykyk π§.-debuginfodβ attempt to look up coverage mapping from objects using debuginfod. This is attempted by default for binary IDs present in the profile but not provided on the command line, so long as debuginfod is compiled in and configured viaDEBUGINFOD_URLS.-debug-file-directory=<dir>β provides a directory to search for objects corresponding to binary IDs in the profile.-check-binary-idsβ fail if an object file cannot be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup. Strict queen behavior π.-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profile. Pick one, bestie, you can't have both π.
π¦ EXPORT COMMAND π¦
SYNOPSIS
llvm-cov export [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
DESCRIPTION
llvm-cov export exports coverage data of the binaries BIN... using the profile data PROFILE, in either JSON or lcov trace file format. Two formats, both iconic π
.
When exporting JSON, the regions, functions, branches, expansions, and summaries of the coverage data will be exported. When exporting an lcov trace file, the line-based coverage, branch coverage, and summaries will be exported. Different format, different slay β¨.
The exported data can optionally be filtered to only export the coverage for the files listed in SOURCE....
For information on compiling programs for coverage and generating profile data, see SHOW COMMAND πΈ.
OPTIONS π
-arch=<name>β if the covered binary is a universal binary, select the architecture to use. It is an error to specify an architecture that is not included in the universal binary or to use an architecture that does not match a non-universal binary. Same rule as before, no cap π«Ά.-format=<FORMAT>β use the specified output format. The supported formats are:"text"(JSON) and"lcov".-summary-onlyβ export only summary information for each file in the coverage data. This mode will not export coverage information for smaller units such as individual functions or regions. The result will contain the same information as produced by thellvm-cov reportcommand, but presented in JSON or lcov format rather than text. Big picture only, we love a minimalist π.-ignore-filename-regex=<PATTERN>β skip source code files with file paths that match the given regular expression.-skip-expansionsβ skip exporting macro expansion coverage data.-skip-functionsβ skip exporting per-function coverage data.-show-mcdc-non-executed-vectorsβ when MC/DC data is present in the export, include test vectors that were not executed (for JSON, these appear with"executed": falsealongside executed vectors). By default, only executed MC/DC test vectors are exported. Opt in if you wanna see the ones that stayed home π.-num-threads=N,-j=Nβ useNthreads to export coverage data. WhenN=0,llvm-covauto-detects an appropriate number of threads to use. This is the default. Multithreaded queen β‘.-compilation-dir=<dir>β directory used as a base for relative coverage mapping paths. Only applicable when binaries have been compiled with one of-fcoverage-prefix-map,-fcoverage-compilation-dir, or-ffile-compilation-dir.-debuginfodβ attempt to look up coverage mapping from objects using debuginfod. This is attempted by default for binary IDs present in the profile but not provided on the command line, so long as debuginfod is compiled in and configured viaDEBUGINFOD_URLS.-debug-file-directory=<dir>β provides a directory to search for objects corresponding to binary IDs in the profile.-check-binary-idsβ fail if an object file cannot be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup.-empty-profileβ export the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profile. Again β one or the other, not both π.
π§ CONVERT-FOR-TESTING COMMAND π§
Warning: This command is for the LLVM developers who are working on llvm-cov only. Like, respectfully, it's not for us randoms π β it's an internal dev thing.
SYNOPSIS
llvm-cov convert-for-testing BIN -o OUT
DESCRIPTION
The llvm-cov convert-for-testing command serves the purpose of testing llvm-cov itself. It can extract all code coverage data from the binary BIN to the file OUT, thereby reducing the size of test files. The output file typically bears the .covmapping extension.
The .covmapping files can be read back by llvm-cov just as ordinary binary files. Round trip, we love a circular moment π.
π Author π
Maintained by the LLVM Team (<https://llvm.org/>). Iconic maintainers, fr fr.
π Copyright π
2003-2026, LLVM Project
okay bestie that's the whole page, we ate and left no crumbs π
β¨ this was LLVM-COV(1) from the LLVM source, dated 2026-10-20, page 23 β see u in the group chat, mwah π«Άπ
π¦ where this page comes from
- arch rolling: llvm 23.1.4-1 Β· Apache-2.0 WITH LLVM-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms