https://bugs.llvm.org/show_bug.cgi?id=36322

            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
          Assignee: unassignedclangb...@nondot.org
          Reporter: paul_robin...@playstation.sony.com
                CC: llvm-bugs@lists.llvm.org

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_TAG_array_type 
        DW_AT_type -> "int"
        DW_TAG_subrange_type 
          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
(https://bugs.llvm.org/show_bug.cgi?id=30553#c3) and to keep the generated
DWARF within a reasonable size, I would suggest the GCC aproach as a size
optimization.

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
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to