Bug ID: 36322
           Summary: Simpler DWARF for C99 VLAs
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen

Filed on behalf of Carlos Enciso, who made this post-commit suggestion
on Phabricator D41698:

Hi @sdesmalen!

For the following test case

  int main() {
    int size = 2;

    int var[size];
    var[1] = 1;

    return 0;

I compared the DWARF generated by GCC and it looks like

  DW_TAG_variable "var"
    DW_AT_location ...
    DW_AT_type DW_FORM_ref4
        DW_AT_type -> "int"
          DW_AT_type -> "sizetype"
          DW_AT_upper_bound DW_FORM_exprloc [4] = { DW_OP_fbreg 0xffffffb8
DW_OP_deref }

GCC use DW_AT_upper_bound with an associated location expression to describe
the VLA boundaries.

In order to reduce the side effects created by the artifical-variable as
described in my previous comment
( and to keep the generated
DWARF within a reasonable size, I would suggest the GCC aproach as a size

The DWARF description of the artificial-variable could be removed and its
location expression used by the array's subrange_type, instead of the
subrange_type making a reference to the artificial-variable.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to