[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

Carlos Alberto Enciso via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 06:56:49 PST 2018


CarlosAlbertoEnciso added a comment.

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


Repository:
  rL LLVM

https://reviews.llvm.org/D41698





More information about the llvm-commits mailing list