[DebugInfo] Support for DWARF attribute DW_AT_rank

This patch adds support for DWARF attribute DW_AT_rank.

  Summary:
Fortran assumed rank arrays have dynamic rank. DWARF attribute
DW_AT_rank is needed to support that.

  Testing:
unit test cases added (hand-written)
check llvm
check debug-info

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D89141
This commit is contained in:
Alok Kumar Sharma
2020-10-10 17:48:35 +05:30
parent 0db08e59c9
commit 96bd4d34a2
17 changed files with 404 additions and 72 deletions

View File

@@ -1362,7 +1362,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_COMPOSITE_TYPE: {
if (Record.size() < 16 || Record.size() > 20)
if (Record.size() < 16 || Record.size() > 21)
return error("Invalid record");
// If we have a UUID and this is not a forward declaration, lookup the
@@ -1389,6 +1389,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Metadata *DataLocation = nullptr;
Metadata *Associated = nullptr;
Metadata *Allocated = nullptr;
Metadata *Rank = nullptr;
auto *Identifier = getMDString(Record[15]);
// If this module is being parsed so that it can be ThinLTO imported
// into another module, composite types only need to be imported
@@ -1417,6 +1418,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Associated = getMDOrNull(Record[18]);
Allocated = getMDOrNull(Record[19]);
}
if (Record.size() > 20) {
Rank = getMDOrNull(Record[20]);
}
}
DICompositeType *CT = nullptr;
if (Identifier)
@@ -1424,7 +1428,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Context, *Identifier, Tag, Name, File, Line, Scope, BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Discriminator, DataLocation, Associated,
Allocated);
Allocated, Rank);
// Create a node if we didn't get a lazy ODR type.
if (!CT)
@@ -1433,7 +1437,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
SizeInBits, AlignInBits, OffsetInBits, Flags,
Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator, DataLocation, Associated,
Allocated));
Allocated, Rank));
if (!IsNotUsedInTypeRef && Identifier)
MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));