[PATCH] D45026: [DebugInfo] Add bitcode reader/writer for DILabel metadata.
Hsiangkai Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 29 06:59:01 PDT 2018
HsiangKai created this revision.
HsiangKai added reviewers: rnk, chenwj.
Herald added a subscriber: JDevlieghere.
Create new MetadataCodes METADATA_LABEL. Bitcode reader will use GET_OR_DISTINCT()
to create DILabel objects and store the objects into LLVMContext.
In addition, implement bitcode writer in ModuleBitcodeWriter.
Repository:
rL LLVM
https://reviews.llvm.org/D45026
Files:
include/llvm/Bitcode/LLVMBitCodes.h
lib/Bitcode/Reader/MetadataLoader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -331,6 +331,8 @@
unsigned Abbrev);
void writeDILocalVariable(const DILocalVariable *N,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
+ void writeDILabel(const DILabel *N,
+ SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDIExpression(const DIExpression *N,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDIGlobalVariableExpression(const DIGlobalVariableExpression *N,
@@ -1779,6 +1781,19 @@
Record.clear();
}
+void ModuleBitcodeWriter::writeDILabel(
+ const DILabel *N, SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back((uint64_t)N->isDistinct());
+ Record.push_back(VE.getMetadataOrNullID(N->getScope()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+ Record.push_back(VE.getMetadataOrNullID(N->getFile()));
+ Record.push_back(N->getLine());
+
+ Stream.EmitRecord(bitc::METADATA_LABEL, Record, Abbrev);
+ Record.clear();
+}
+
void ModuleBitcodeWriter::writeDIExpression(const DIExpression *N,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
Index: lib/Bitcode/Reader/MetadataLoader.cpp
===================================================================
--- lib/Bitcode/Reader/MetadataLoader.cpp
+++ lib/Bitcode/Reader/MetadataLoader.cpp
@@ -822,6 +822,7 @@
case bitc::METADATA_TEMPLATE_VALUE:
case bitc::METADATA_GLOBAL_VAR:
case bitc::METADATA_LOCAL_VAR:
+ case bitc::METADATA_LABEL:
case bitc::METADATA_EXPRESSION:
case bitc::METADATA_OBJC_PROPERTY:
case bitc::METADATA_IMPORTED_ENTITY:
@@ -1647,6 +1648,20 @@
NextMetadataNo++;
break;
}
+ case bitc::METADATA_LABEL: {
+ if (Record.size() < 4)
+ return error("Invalid record");
+
+ IsDistinct = Record[0] & 1;
+ MetadataList.assignValue(
+ GET_OR_DISTINCT(DILabel,
+ (Context, getMDOrNull(Record[1]),
+ getMDString(Record[2]),
+ getMDOrNull(Record[3]), Record[4])),
+ NextMetadataNo);
+ NextMetadataNo++;
+ break;
+ }
case bitc::METADATA_EXPRESSION: {
if (Record.size() < 1)
return error("Invalid record");
Index: include/llvm/Bitcode/LLVMBitCodes.h
===================================================================
--- include/llvm/Bitcode/LLVMBitCodes.h
+++ include/llvm/Bitcode/LLVMBitCodes.h
@@ -310,6 +310,7 @@
METADATA_GLOBAL_VAR_EXPR = 37, // [distinct, var, expr]
METADATA_INDEX_OFFSET = 38, // [offset]
METADATA_INDEX = 39, // [bitpos]
+ METADATA_LABEL = 40, // [distinct, scope, name, file, line]
};
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45026.140223.patch
Type: text/x-patch
Size: 3091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/a174de30/attachment.bin>
More information about the llvm-commits
mailing list