llvm / llvm/llvm-project

Incorrect coverage report for shared library with __llvm_profile_write_file(void);

Open
#179,660 4 comments 0 reactions 0 assignees View on GitHub
coverage
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I am observing that llvm-cov does not report any coverage data for functions located in a shared library when the application exits using _exit(), even though profiling data is explicitly written using __llvm_profile_write_file().

This results in missing coverage information for shared libraries, while coverage for the main executable is reported correctly.

llvm-cov show --instr-profile=app.profdata myapp
/scratch/ankurraj/icx2025.3/shlib/foo.c:
1| |#include
2| |
3| 0|void foo(void){
4| |
5| 0| printf("Hellow world from foo\n");
6| 0|}

/scratch/ankurraj/icx2025.3/shlib/main.c:
1| |#include
2| |#include "foo.h"
3| |#include
4| |int __llvm_profile_write_file(void);
5| |
6| |
7| 1|int main() {
8| 1| printf("[main] calling foo()\n");
9| 1| foo();
10| 1| printf("[main] returned from foo()\n");
11| 1| __llvm_profile_write_file();
12| 1| _exit(0); << -- this is delebrate
13| 1|}

No Data was dumped for shared libraies

Contributor guide

Open the contributing guide

Research direction

Reproduce the example with llvm-cov show --instr-profile=app.profdata myapp, focusing on the shared-library foo() path after __llvm_profile_write_file() and _exit(0). Done means the generated profile report includes executed functions from the shared library as well as the main executable.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
devtools, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.