llvm / llvm/llvm-project

[llvm-cov] openmp leads to wrong coverage

Open
#173,230 1 comment 0 reactions 0 assignees View on GitHub
coverage openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The `#pragma omp simd` leads to wrong coverage

Target compiler:
```
$ clang-trunk -v
clang version 22.0.0git (https://github.com/llvm/llvm-project.git a8dc57f0d7253df172b554dc3e3f4790913d578d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /compiler/llvm-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

Case:
```
$ cat small.c
int a;
int main() {
#pragma omp simd
for (int b = 0; b < 5; b++) {
a = 0 == 0;
if (a != (b != 'a'))
__builtin_abort();
}
}
```

Wrong coverage:
```
$ clang-trunk -w -O0 -fcoverage-mapping -fopenmp -fprofile-instr-generate=small.c.profraw small.c -o small && ./small && /compiler/llvm-trunk/bin/llvm-profdata merge small.c.profraw -o small.c.profdata && /compiler/llvm-trunk/bin/llvm-cov show small -instr-profile=small.c.profdata small.c
1| |int a;
2| 6|int main() {
3| 6|#pragma omp simd
4| 6| for (int b = 0; b < 5; b++) {
5| 6| a = 0 == 0;
6| 6| if (a != (b != 'a'))
7| 6| __builtin_abort();
8| 6| }
9| 6|}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the report with small.c using clang-trunk, -fopenmp, coverage mapping, llvm-profdata, and llvm-cov show. Compare the displayed counts with execution of the sample and inspect the compiler and coverage-tool paths involved in OpenMP SIMD instrumentation. Done means llvm-cov reports correct coverage for the sample without breaking related coverage behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.