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

    <tr>
        <th>Summary</th>
        <td>
            Shared variables in OpenMP outlined regions have the wrong types in DWARF
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            wrong-debug,
            debuginfo,
            clang:openmp
      </td>
    </tr>

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

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

<pre>
    This issue is similar to #107125. 

Based on a code like:
```C
#include <omp.h>
#include <stdio.h>

int main(int argc, char **argv) {
  const int n = 100 * argc;
  double a[n], total=42., c = .3;
#pragma omp parallel for reduction(+ : total) 
  for (int i = 0; i < n; i++) {
    total += a[i] = i * c;
  }
 printf("total=%lf, expected:%lf, a[50]=%lf\n", total, c * n * (n - 1) / 2, a[50]);
}
```

compiled as:

```
clang -g -fopenmp test-dwarf.c
llvm-dwarfdump
```
Produces something like:

```
0x000000de:     DW_TAG_formal_parameter
 DW_AT_location        (DW_OP_fbreg -48)
                  DW_AT_name ("a")
                  DW_AT_decl_file       ("test-dwarf.c")
 DW_AT_decl_line       (6)
                  DW_AT_type (0x000001e6 "double &")

0x000000e9:     DW_TAG_formal_parameter
 DW_AT_location        (DW_OP_fbreg +16)
 DW_AT_name    ("c")
                  DW_AT_decl_file ("test-dwarf.c")
                  DW_AT_decl_line       (6)
 DW_AT_type    (0x000001e6 "double &")
```
With debuginfo like the following (put together from gcc output and type information in main), the debugger would be able to provide more sensible output for the variables:
```
0x000000de:     DW_TAG_formal_parameter
 DW_AT_location        (DW_OP_fbreg -48, DW_OP_deref)
 DW_AT_name    ("a")
                  DW_AT_decl_file ("test-dwarf.c")
                  DW_AT_decl_line       (6)
 DW_AT_type    (0x000001c8 "double[]")

0x000000e9: DW_TAG_formal_parameter
                  DW_AT_location (DW_OP_fbreg +16, DW_OP_deref)
                  DW_AT_name    ("c")
 DW_AT_decl_file       ("test-dwarf.c")
 DW_AT_decl_line       (6)
                  DW_AT_type    (0x000001c4 "double")
```
The type information should be the same as in main, the parameter passed by reference must be dereferenced in the location descriptor.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVtuOozgTfhrnppQITAjhgosk_PmvVjPabakvI4ML8KyxkW3S0_v0Kxty6J4-7Eh7QBFN21VfVX11sJm1olWIBUn3JC0XbHSdNsW3wWj3By4qzZ-Lh05YENaOCMKCFb2QzIDTQGgSR1lM0xWQqCTRbnrvmUUOWgGDWnMEKX5HksybZBNNv8P8P02EquXIEUhy0P2w6kjyv7f2rONC3--Gt1AOeiYUoVv_yUxbE3qAumMGCN0RumOmPROaA8n2kwpArZV14OUVkKSEOIq88KSdXMW4HiuJwEi6VyQtPa7TjkmSlGu6CmaC-iq5KhGaDIa1PQPdDzAww6RECY02YJCPtRPau0roHkiym-G8c7NJLziHIgJ2RJJ9-DyACp-E7sPvRUAwIYHfScrgsSBpGRBECO0-LpKV8-dghHJNcIheQiM0lY0PDr8PWDvkPneXNY-cRp6Mi2B6UITSGzcTK3TnqaU7H4yCJcTBYXoE-hKF5jfqLl5dS-Q-z7XuByGRA7O3WnpLvJZMtbBsYdnoAVU_gEPrlvyJmWZVTzJSnvtphY_98CbMV6P5WKMFq3t0nVDtqzp-Syn6HoWHezmfFSgfTw-7_58abXomT74eenRoZvrLx9Pu4SR1zXxdwPwQui0fT1--nprKYAvL9dbTdM30y2eCUKxHmNLIQjY-kedYy1MjJN5M-gq4J-oe5U5JCnWntPnUknsegmczNTFugFA6dxahm3s7L0nE_G8kkdB9vHkdUGDtGn39c8R9QtlH-u9yeEfZtPeXWHtZg4_CdcCxGluhGh2KFlyH0Ggp9ZOvY0K3w-jA6RZdhwYao3to6xr06PwGUxyCDx7A9BOtQs1jNg-t3uFko0UDT3qUHCoE5r1zGgajz4Ij9NogWFRW-I0Z3U84r35mRngF--PR8E830wGmJY4Gm4-L4ie76V8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