Skip to content

[llvm-cov] openmp leads to wrong coverage #173230

@iamanonymouscs

Description

@iamanonymouscs

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|}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions