LLVM-COV(1)
π llvm-cov β emit coverage information
okay bestie, welcome to llvm-cov, the LLVM manual page, and honestly? it's giving β¨main character energyβ¨ because it's a whole suite of tools wearing one trenchcoat. let's get into it π«Ά
πΈ SYNOPSIS
llvm-cov command [args...]
π¦ DESCRIPTION
so llvm-cov shows you code coverage information for programs that are instrumented to emit profile data. that's the whole vibe. you can use it to work with gcov-style coverage, or with clang's instrumentation based profiling. both. either. iconic of it tbh.
and here's a little plot twist for you: if the program gets invoked with a base name of gcov, it just behaves as if the llvm-cov gcov command were called. sneaky! otherwise, bestie, you gotta provide a command. no command, no coverage, no slay. π
π COMMANDS
these are the flavors, pick your fighter:
gcovshowreportexport
π GCOV COMMAND
β¨ SYNOPSIS
llvm-cov gcov [options] SOURCEFILE
π DESCRIPTION
okay so the llvm-cov gcov tool reads code coverage data files and displays the coverage info for a source file you pick. it's compatible with the gcov tool from version 4.2 of GCC, and it may also be compatible with some later versions of gcov. may!! no promises!! π
to use llvm-cov gcov, you first have to build an instrumented version of your app that collects coverage data as it runs. compile with the -fprofile-arcs and -ftest-coverage options to add that instrumentation. (or alternatively, use the --coverage option, which just includes both of those other options β two birds, one flag, we love efficiency π
)
the way that this works: at the time you compile the instrumented code, a .gcno data file gets generated for each object file. those .gcno files hold half of the coverage data. the other half comes from .gcda files, which get generated when you run the instrumented program β and there's a separate .gcda file for each object file, periodt.
β οΈ heads up bestie: every single time you run the program, the execution counts get summed into any existing .gcda files. so if you don't want old data mixed in, go delete those old files first. not a drill. π₯
by default, the .gcda files get 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. here's how those two work together:
GCOV_PREFIX_STRIPspecifies 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_PREFIXvariable gets added.
these env vars let you run the instrumented program on a machine where the original object file directories aren't accessible. but β and this is the catch β you'll then need to copy the .gcda files back to the object file directories where llvm-cov gcov expects to find them. so it's a little field trip for your files π§
once you've generated the coverage data files, run llvm-cov gcov for each main source file where you want to examine the coverage results. run it from the same directory where you previously ran the compiler (yes, that matters π). the results for the specified source file get written to a file named by appending a .gcov suffix. and a separate output file also gets created for each file included by the main source file, also with a .gcov suffix added. everyone gets a file, we're inclusive here.
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 shows as - if a line doesn't contain any executable code. and if a line does contain code but that code was never executed, the count is displayed as #####. dramatic but accurate π
β OPTIONS
-a,--all-blocksβ display all basic blocks. if there are multiple blocks for a single line of source code, this makesllvm-covshow the count for each block instead of just one count for the entire line. more data, more fun.-b,--branch-probabilitiesβ display conditional branch probabilities, plus a summary of branch information. πΏ-c,--branch-countsβ display branch counts instead of probabilities. (requires-b! don't forget the-b, bestie π«Ά)-m,--demangled-namesβ demangle function names. give those names their glow-up β¨-f,--function-summariesβ show a summary of coverage for each function, instead of just one summary for an entire source file.--helpβ display available options. (--help-hiddenfor more, if you're nosy π)-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 though, so you're not missing out.-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 separated 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.-s <string>β source prefix to elide.-t,--stdoutβ print to stdout instead of producing.gcovfiles. stream it straight to your eyeballs π-u,--unconditional-branchesβ include unconditional branches in the output for the--branch-probabilitiesoption.-versionβ display the version ofllvm-cov.-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 the MD5 hash calculated for it. cryptographic glow-up π
π EXIT STATUS
llvm-cov gcov returns 1 if it can't read input files. otherwise, it exits with zero. simple as that, no cap. π
β¨ SHOW COMMAND β¨
π SYNOPSIS
llvm-cov show [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π DESCRIPTION
okay so llvm-cov show is the one that goes line by line through your binaries BIN... and shows you the coverage using the profile data in PROFILE. you can also filter it so it only shows the tea for the files you listed in SOURCE... β bestie behaviour honestly. π
and BIN? it can be literally any of these: an executable, an object file, a dynamic library, or an archive (thin or otherwise). slay, versatile. β¨
to actually use llvm-cov show you need a program that was compiled with instrumentation so it emits profile and coverage data. to build one of those with clang, you use the -fprofile-instr-generate and -fcoverage-mapping flags. and 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. no skipping that step, it matters. π«Ά
the coverage info lives inside the built executable or library itself, and that's the thing you hand over to llvm-cov show as a BIN argument. the profile data comes from running that instrumented program like normal β when it exits it writes out a raw profile file, usually called default.profraw, and you convert that into something suitable for the PROFILE argument using the llvm-profdata merge tool. it's giving pipeline. it's giving main character workflow. π
π₯ OPTIONS π₯
-show-branches=<VIEW>β show coverage for branch conditions, either as a count or a percentage. the supported views are:"count","percent". pick your fighter. π-show-mcdcβ show modified condition/decision coverage (MC/DC) for each applicable boolean expression. fancy AND thorough, we love that for you. β¨-show-line-countsβ show the execution counts for each line. defaults to true, unless another-showoption gets used. π-show-expansionsβ expand inclusions, like preprocessor macros or textual inclusions, inline in the display of the source file. defaults to false.-show-instantiationsβ for source regions that get instantiated multiple times (looking at you, C++ templates π), show each instantiation separately and the combined summary. defaults to true.-show-regionsβ show the 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β show the execution counts for each line if there's only one region on the line, but show the individual regions if there are multiple on the line. defaults to false.-show-directory-coverageβ generate 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β enable or disable color output. by default this is autodetected. β¨-arch=[*NAMES*]β specify a list of architectures where the Nth entry lines up with the Nth specified binary. if the covered object is a universal binary, this says which architecture to use. it is an error to specify an architecture that's not included in the universal binary, or to use an architecture that doesn't match a non-universal binary. β οΈ-name=<NAME>β show code coverage only for functions with the given name.-name-allowlist=<FILE>β show 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>β show code coverage only for functions that match the given regular expression.-ignore-filename-regex=<PATTERN>β skip source code files whose file paths match the given regular expression.-format=<FORMAT>β use the specified output format. the supported formats are:"text","html".-tab-size=<TABSIZE>β replace tabs with<TABSIZE>spaces when preparing reports. currently this is only supported for thehtmlformat. (iykyk) π-output-dir=PATHβ specify a directory to write coverage reports into. if the directory doesn't exist, it gets 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>β specify 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β use N threads 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>β show code coverage only for functions with line coverage greater than the given threshold.-line-coverage-lt=<N>β show code coverage only for functions with line coverage less than the given threshold.-region-coverage-gt=<N>β show code coverage only for functions with region coverage greater than the given threshold.-region-coverage-lt=<N>β show code coverage only for functions with region coverage less than the given threshold.-path-equivalence=<from>,<to>β map the paths in the coverage data to local source file paths. this lets you generate the coverage data on one machine and 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're specified. if multiple mappings can be applied to a single path, the first mapping encountered is used. π-coverage-watermark=<high>,<low>β set high and low watermarks for coverage inhtmlformat output. this lets you set the high and low watermark of coverage as desired: green when coverage>= high, red when coverage< low, and yellow otherwise. both high and low should be between0-100andhigh > low. π¨-debuginfodβ use 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β fail if an object file can't be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup. π-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profile. (can't have both bestie, pick one π)
π REPORT COMMAND π
π SYNOPSIS
llvm-cov report [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π DESCRIPTION
llvm-cov report is the summary girly of the family. it displays a summary of the coverage of the binaries BIN... using the profile data PROFILE, and it can optionally be filtered to only show coverage for the files listed in SOURCE.... π
and again, BIN can be an executable, an object file, a dynamic library, or an archive (thin or otherwise). iconic range. β¨
if no source files are provided, a summary line gets printed for each file in the coverage data. if any files are provided, summaries can be shown for each function in the listed files β but only if the -show-functions option is enabled. π
for info on compiling programs for coverage and generating profile data, see SHOW COMMAND. (it's right up there bestie, go look π«Ά)
π₯ OPTIONS π₯
-use-color[=VALUE]β enable or disable color output. by default this is autodetected.-arch=<name>β if the covered binary is a universal binary, select the architecture to use. it is an error to specify an architecture that's not included in the universal binary, or to use an architecture that doesn't match a non-universal binary. β οΈ-show-region-summaryβ show statistics for all regions. defaults to true.-show-branch-summaryβ show statistics for all branch conditions. defaults to true.-show-mcdc-summaryβ show MC/DC statistics. defaults to false.-show-functionsβ show coverage summaries for each function. defaults to false.-show-instantiation-summaryβ show statistics for all function instantiations. defaults to false.-ignore-filename-regex=<PATTERN>β skip source code files whose file paths match the given regular expression.-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 can't be found for a binary ID present in the profile, neither on the command line nor via binary ID lookup. π-empty-profileβ display the baseline coverage of the binaries with all zero execution counts. mutually exclusive with-instr-profile. (again β pick one, not both π)
β¨ EXPORT COMMAND β¨
πΈ SYNOPSIS πΈ
llvm-cov export [options] -instr-profile PROFILE [BIN] [-object BIN]...
[-sources] [SOURCE]...
π¦ DESCRIPTION π¦
Okay bestie so the llvm-cov export command is the one that ships your coverage data out the door π β it takes the coverage data from the binaries BIN... and, using the profile data PROFILE, exports it in either JSON or lcov trace file format. Pick your fighter.
When you're exporting JSON, what gets exported is the regions, functions, branches, expansions, and summaries of the coverage data. When you're exporting an lcov trace file instead, you get the line-based coverage, branch coverage, and summaries. Different format, different vibe, same data underneath, iykyk π
And if you want, the exported data can be filtered β you can tell it to only export the coverage for the files listed in SOURCE.... Very demure, very selective π
Wanna know how to actually compile programs for coverage and generate profile data in the first place? That's all in SHOW COMMAND, go look π«Ά
π OPTIONS π
-arch=<name>β if the covered binary is a universal binary, this picks which architecture to use. And heads up: it is an error to specify an architecture that isn't actually in the universal binary, or to use an architecture that doesn't match a non-universal binary. So likeβ¦ don't do that π-format=<FORMAT>β use the specified output format. The supported formats are:"text"(JSON), and"lcov". That's the whole menu bestie.-summary-onlyβ export only the summary information for each file in the coverage data. This mode will not export coverage info for smaller units like individual functions or regions. The result contains the same information that thellvm-cov reportcommand produces, but presented in JSON or lcov format rather than text. Same tea, different cup β-ignore-filename-regex=<PATTERN>β skip source code files whose file paths match the given regular expression. Begone, irrelevant files π«-skip-expansionsβ skip exporting macro expansion coverage data. No expansions today, thank you π-skip-functionsβ skip exporting per-function coverage data. Functions? Never heard of her π-num-threads=N,-j=Nβ useNthreads to export coverage data. WhenN=0,llvm-covauto-detects an appropriate number of threads to use β and that's the default. She multitasks β¨-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. Conditional queen π-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. Very "I'll find it myself" energy π-debug-file-directory=<dir>β provides a directory to search for objects corresponding to binary IDs in the profile. A lil home for your objects π-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 mode: activated π₯-empty-profileβ export the baseline coverage of the binaries with all zero execution counts. Mutually exclusive with-instr-profileβ you literally cannot have both, they're beefing βοΈ
π CONVERT-FOR-TESTING COMMAND π
β οΈ WARNING: this command is for the LLVM developers who are working onllvm-covonly. It is not for you, bestie, unless you are an LLVM dev working onllvm-cov. Read the room π«£
π§ SYNOPSIS π§
llvm-cov convert-for-testing BIN -o OUT
π DESCRIPTION π
The llvm-cov convert-for-testing command exists for one purpose and one purpose only: testing llvm-cov itself. It can extract all the code coverage data from the binary BIN into the file OUT, which has the side effect of reducing the size of test files. The output file typically rocks the .covmapping extension π
And the plot twist? Those .covmapping files can be read back by llvm-cov just as if they were ordinary binary files. Iconic, honestly π
π AUTHOR π
Maintained by the LLVM Team (https://llvm.org/). They keep the whole thing running, no cap π«Ά
β COPYRIGHT β
2003-2026, LLVM Project β the copyright holding it down since way back π
And that's the whole page, bestie!! π This was the LLVM-COV(1) manual, from the 21 release, dated 2026-07-22 β the source is the LLVM Project and the version number is right there in the footer. Go forth and export your coverage data, you absolute main character πΈπβ¨
π¦ where this page comes from
- epel 10: llvm21 21.1.8-8.el10_3 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: llvm 21.1.8-6.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: llvm 21.1.8-6.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms