Skip to content

Some application variables in OpenMP outlined regions are marked artificial #107125

@jprotze

Description

@jprotze

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:

#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

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.

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