summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2021-07-18 23:43:48 -0700
committerYonghong Song <yhs@fb.com>2021-08-19 15:37:44 -0700
commit2fded193e7a8fb5bd8fb339f00fd9de686390530 (patch)
treeafd5b44042ab762c8c088fceaf4d9917b7baf8e2 /llvm/lib/Bitcode/Reader/MetadataLoader.cpp
parentfd0557dbf13198ddd6a17bd120a7b2bb97bfbd0a (diff)
[DebugInfo] generate btf_tag annotations for DIComposite types
Clang patch D106614 added attribute btf_tag support. This patch generates btf_tag annotations for DIComposite types. A field "annotations" is introduced to DIComposite, and the annotations are represented as an DINodeArray, similar to DIComposite elements. The following example illustrates how annotations are encoded in IR: distinct !DICompositeType(..., annotations: !10) !10 = !{!11, !12} !11 = !{!"btf_tag", !"a"} !12 = !{!"btf_tag", !"b"} Each btf_tag annotation is represented as a 2D array of meta strings. Each record may have more than one btf_tag annotations, as in the above example. Differential Revision: https://reviews.llvm.org/D106615
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 8493eb7a28b2..da6010e1c640 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1461,7 +1461,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_COMPOSITE_TYPE: {
- if (Record.size() < 16 || Record.size() > 21)
+ if (Record.size() < 16 || Record.size() > 22)
return error("Invalid record");
// If we have a UUID and this is not a forward declaration, lookup the
@@ -1489,6 +1489,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Metadata *Associated = nullptr;
Metadata *Allocated = nullptr;
Metadata *Rank = nullptr;
+ Metadata *Annotations = 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
@@ -1520,6 +1521,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
if (Record.size() > 20) {
Rank = getMDOrNull(Record[20]);
}
+ if (Record.size() > 21) {
+ Annotations = getMDOrNull(Record[21]);
+ }
}
DICompositeType *CT = nullptr;
if (Identifier)
@@ -1527,7 +1531,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, Rank);
+ Allocated, Rank, Annotations);
// Create a node if we didn't get a lazy ODR type.
if (!CT)
@@ -1536,7 +1540,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
SizeInBits, AlignInBits, OffsetInBits, Flags,
Elements, RuntimeLang, VTableHolder, TemplateParams,
Identifier, Discriminator, DataLocation, Associated,
- Allocated, Rank));
+ Allocated, Rank, Annotations));
if (!IsNotUsedInTypeRef && Identifier)
MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));