<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107125>107125</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Some application variables in OpenMP outlined regions are marked artificial
</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>
Debuggers use the artificial attribute to identify compiler generated variables. If the attribute is used consistently, the debugger can show application variables while hiding artificial variables. In outlined functions, clang marks all variables as artificial:
```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:
```bash
clang -g -fopenmp test-dwarf.c
llvm-dwarfdump
```
provides this output:
```
0x0000009e: DW_TAG_subprogram
DW_AT_name ("main.omp_outlined_debug__")
...
0x00000102: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -68)
DW_AT_name ("i")
DW_AT_type (0x000001a6 "int")
DW_AT_artificial (true)
...
0x00000134: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -96)
DW_AT_name ("total")
DW_AT_type (0x000001bd "double")
DW_AT_artificial (true)
```
`i` is clearly a local variable and there is no argument for marking it artificial. `total` is also an application variable and should not be marked artifical. Other variables like `a` and `c` are not marked artificial.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVcGOozgQ_RrnUgoCE-hw4JA0m9UeVjPSjjTHyOACPGNsZJvu6f36lQ0kZKdbahQRY8rv1XvYVcxa0SnEkmRnklU7Nrlem_LHaLT7F3e15m9lhfXUdWgsTBbB9QjMONGKRjAJzDkj6skhOA2Co3KifYNGD6OQaKBDhYY55PDC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