RFC: Extending DISubrange count field

Hi,

To improve debug information for variable length arrays (https://bugs.llvm.org/show_bug.cgi?id=30553) I have proposed some changes to Metadata IR’s DISubrange node. To get some wider visibility on this, I’m sharing this as an RFC with llvm-dev.

The proposed change is to extend the ‘count’ field to also accept a Metadata node, rather than only accepting a signed integer. For example:

!10 = !DILocalVariable(name: “count”, scope: !8, file: !6, line: 42, type: !9)

!11 = !DISubrange(count !10, lowerBound: 0)

^^^ references the local variable

This allows specifying the size of an array by referencing the DIE of a local variable that holds the size expression. Another reason to extend the count field is to specify the length with a DIExpression. For instance, we need this to specify the length of an SVE vector as a DWARF expression that is based on a (runtime defined) DWARF pseudo register.

Some preliminary feedback was that we may want to use something similar for lowerBound as well. Also Adrian suggested (https://reviews.llvm.org/D41697#966736) that it may be useful in general to reference Metadata nodes in DIExpressions if we ever need to combine local variables with DWARF expressions. Something like that might be needed to e.g. reference a value from an offset of a pointer when using an array descriptor, although I could use some suggestions on what DWARF code needs to be generated for this general case.

The whole patch-series can be found here:

https://reviews.llvm.org/D41695

https://reviews.llvm.org/D41696

https://reviews.llvm.org/D41697

https://reviews.llvm.org/D41698

Thanks,

Sander