<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/95064>95064</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            coverage incomplete with openmp `omp parallel for collapse(2)`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wheatman
      </td>
    </tr>
</table>

<pre>
    When I try and get a coverage report with a code that uses `omp parallel for collapse(2)` it is missing lines that I can see run.

```cpp
#include <cstdlib>
#include <iostream>
#include <omp.h>

int main(int argc, char **argv) {
 // #pragma omp parallel for collapse(2)
#pragma omp parallel for
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
 std::cout << i << "," << j << "\n";
    }
 }
}
```

the output with a without the collapse 
```
    1| |#include <cstdlib>
    2|       |#include <iostream>
    3| |#include <omp.h>
    4|       |
    5|      1|int main(int argc, char **argv) {
    6|       |  // #pragma omp parallel for collapse(2)
 7|      1|#pragma omp parallel for
    8|     40|  for (int i = 0; i < 100; ++i) {
    9|  9.98k|    for (int j = 0; j < 100; ++j) {
   10| 9.96k|      std::cout << i << "," << j << "\n";
   11|  9.96k| }
   12|     20|  }
   13|      1|}
```

the output with the collapse

```
    1|       |#include <cstdlib>
    2| |#include <iostream>
    3|       |#include <omp.h>
    4|       |
 5|      1|int main(int argc, char **argv) {
    6|      1|#pragma omp parallel for collapse(2)
    7|       |  // #pragma omp parallel for
 8|     40|  for (int i = 0; i < 100; ++i) {
    9|     20|    for (int j = 0; j < 100; ++j) {
   10|      0|      std::cout << i << "," << j << "\n";
   11|      0|    }
   12|     20|  }
   13| 1|}
```

However, just from looking at the output of the program I can tell the print statement is running

I am compiling and running with the following set of commands 

```
clang++-17 run.cpp -fprofile-instr-generate -fcoverage-mapping -fopenmp -o basic
./basic 100 > del
llvm-profdata merge -sparse *.profraw -o data.profdata
llvm-cov show basic -instr-profile=data.profdata -show-expansions run.cpp
```

```
clang++-17 --version
Ubuntu clang version 17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lsnSmzgQgJ9GvnRBCYHBHDh4iWvyAFNzFtAGOUKiJGEnlzz7lFi8TH7_WYdygVCvtD7Jza0VjUIsyHpH1ocVH1yrTXFtkbuOq1Wp6y_FPy0q-AjOfAGuamjQAYdKX9DwBsFgr42Dq3DtOF0juJY7GCxaICnVXQ89N1xKlHDSBiotJe8tErZhhOUkpSAcCAudsFaoBqRQaCcnH6HiCiwimEGFhB4I3c73lE6_qu_nGRYLVcmhRiDxvrKulqIk8Ye3pEJbZ5B3L8S668P2LhvvQjnouFCEbfyQm6YibA9Vyw0QtiVsy01zISwHku0mEyDsSNgRCIt7w5uOw3eLsSTzQn_2O5rOiQgg8QEoiXfjcA8RHV8I2xG2E88JwZPp-W56_tb0_GxqXU3iLYm3lR6c1_YGYhkQxgjbE8aWifOjZL1X_hE_pEGyw1KkZXQfLGv7WH_XIujB9cONNf_wuXjJUkd404MPGJFsDyTbv4-J12Rec7q-0f8GHK8Vv-n6GSKvlzw7vs2vb_M-yV8BDQDSJ-fwq-xB9pTM91EE2CwWCR1HvwFnPjrIw3zzaXb6q7gCRGM2eZinn26f9GchjqIl3SnEnWmA6EYRm6ryJIyfi_xT4D_i_uaJ-B_mX5D8kvyfYP6F6x8k_w9j_z6uL2gHeAD-BzfObPrHsb-z8vvYjxf9f7l_DPGT6H-f-r_0FS9oPALnwTo4Gd2B1PqT7xD4dOjPu0Kfxrfe6Mbwbu4ZHEo5T_siWscddqjGRsMMSgnVPIb7CLyDSne9kGMAVS9a90130lLqq5-yOEatdNdxVVt4ZxtWkqtmWqogysY2pup7CE690SchMRDKOhM0qNBwhxCcls4q6Hjf-2jBSfeouh4CDSW3opo8h4Qdx1cPBJD4A9QoJ5GUly7wAWruOHRo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