This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Support for DW_AT_associated and DW_AT_allocated.
ClosedPublic

Authored by alok on Jul 10 2020, 4:17 AM.

Details

Summary

This support is needed for the Fortran array variables with pointer/allocatable
attribute. This support enables debugger to identify the status of variable
whether that is currently allocated/associated.

for pointer array (before allocation/association)
without DW_AT_associated

(gdb) pt ptr
type = integer (140737345375288:140737354129776)
(gdb) p ptr
value requires 35017956 bytes, which is more than max-value-size

with DW_AT_associated

(gdb) pt ptr
type = integer (:)
(gdb) p ptr
$1 = <not associated>

for allocatable array (before allocation)

without DW_AT_allocated

(gdb) pt arr
type = integer (140737345375288:140737354129776)
(gdb) p arr
value requires 35017956 bytes, which is more than max-value-size

with DW_AT_allocated

(gdb) pt arr
type = integer, allocatable (:)
(gdb) p arr
$1 = <not allocated>

Testing
  • unit test cases added
  • check-llvm
  • check-debuginfo

Diff Detail

Event Timeline

alok created this revision.Jul 10 2020, 4:17 AM
Herald added a project: Restricted Project. · View Herald Transcript

Mechanically, this looks great! it would be good to add a little more context to the LangRef documentation (see my inline comment).

llvm/docs/LangRef.rst
4890

Thank you for updating LangRef!
For someone unfamiliar with the concept of an associated array, it would be great to add a sentence that explains that this is a Fortran feature and what it means in broad terms.

llvm/include/llvm/IR/DebugInfoMetadata.h
945–946

@dblaikie At some point I'm going to become concerned by the number of pointer-sized fields in DICompositeType and recommend to split it up into subclasses for C++ and Fortran. But maybe we're not there yet.

Apparently in a current Clang we have

$ dwarfdump bin/clang.dSYM | egrep '(DW_TAG_class_type|DW_TAG_structure_type)' |wc -l
 1011605

on the order of a million unique types, so this patch adds ~16Mb to a full LTO build of Clang. That honestly does not sound too bad.

llvm/test/DebugInfo/X86/dwarfdump-allocatedExp.ll
7

add CHECK-NOT: DW_TAG in between to ensure we're still in the same TAG

dblaikie added inline comments.Jul 14 2020, 12:39 PM
llvm/include/llvm/IR/DebugInfoMetadata.h
945–946

Yeah, definitely something to keep in mind. Might be worth having a metric/buildbot/something that tests peak memory usage of an LTO selfhost build, maybe?

alok marked 2 inline comments as done.Jul 15 2020, 9:45 AM

Mechanically, this looks great! it would be good to add a little more context to the LangRef documentation (see my inline comment).

Thanks a lot for your comments. Your comments will be incorporated in next version of patch

llvm/test/DebugInfo/X86/dwarfdump-allocatedExp.ll
7

Thanks for your comment. This will be incorporated in next version.

alok updated this revision to Diff 278254.Jul 15 2020, 11:16 AM
alok marked an inline comment as done.
alok edited the summary of this revision. (Show Details)

Incorporated comments from @aprantl .

aprantl accepted this revision.Jul 17 2020, 9:58 AM
This revision is now accepted and ready to land.Jul 17 2020, 9:58 AM
This revision was automatically updated to reflect the committed changes.