Skip to content

Shared variables in OpenMP outlined regions have the wrong types in DWARF #110698

Open
@jprotze

Description

@jprotze

This issue is similar to #107125.

Based on a code like:

#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.

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