summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorAmjad Aboud <amjad.aboud@intel.com>2015-12-10 12:56:35 +0000
committerAmjad Aboud <amjad.aboud@intel.com>2015-12-10 12:56:35 +0000
commita9bcf16ebc8a3dbfc4999ddca63f064c29e89f6c (patch)
tree8c1f97f76f047d536f76f983304683adce045d6b /llvm/lib/Bitcode
parentdd76cc1920b348276684c92cbd951c40922be8aa (diff)
downloadbcm5719-llvm-a9bcf16ebc8a3dbfc4999ddca63f064c29e89f6c.tar.gz
bcm5719-llvm-a9bcf16ebc8a3dbfc4999ddca63f064c29e89f6c.zip
Macro debug info support in LLVM IR
Introduced DIMacro and DIMacroFile debug info metadata in the LLVM IR to support macros. Differential Revision: http://reviews.llvm.org/D14687 llvm-svn: 255245
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp30
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp28
2 files changed, 55 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index e95aba771b9..4b5af3dd80f 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2214,10 +2214,10 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
break;
}
case bitc::METADATA_COMPILE_UNIT: {
- if (Record.size() < 14 || Record.size() > 15)
+ if (Record.size() < 14 || Record.size() > 16)
return error("Invalid record");
- // Ignore Record[1], which indicates whether this compile unit is
+ // Ignore Record[0], which indicates whether this compile unit is
// distinct. It's always distinct.
MDValueList.assignValue(
DICompileUnit::getDistinct(
@@ -2226,7 +2226,9 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
Record[6], getMDString(Record[7]), Record[8],
getMDOrNull(Record[9]), getMDOrNull(Record[10]),
getMDOrNull(Record[11]), getMDOrNull(Record[12]),
- getMDOrNull(Record[13]), Record.size() == 14 ? 0 : Record[14]),
+ getMDOrNull(Record[13]),
+ Record.size() <= 15 ? 0 : getMDOrNull(Record[15]),
+ Record.size() <= 14 ? 0 : Record[14]),
NextMDValueNo++);
break;
}
@@ -2294,6 +2296,28 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) {
NextMDValueNo++);
break;
}
+ case bitc::METADATA_MACRO: {
+ if (Record.size() != 5)
+ return error("Invalid record");
+
+ MDValueList.assignValue(
+ GET_OR_DISTINCT(DIMacro, Record[0],
+ (Context, Record[1], Record[2],
+ getMDString(Record[3]), getMDString(Record[4]))),
+ NextMDValueNo++);
+ break;
+ }
+ case bitc::METADATA_MACRO_FILE: {
+ if (Record.size() != 5)
+ return error("Invalid record");
+
+ MDValueList.assignValue(
+ GET_OR_DISTINCT(DIMacroFile, Record[0],
+ (Context, Record[1], Record[2],
+ getMDOrNull(Record[3]), getMDOrNull(Record[4]))),
+ NextMDValueNo++);
+ break;
+ }
case bitc::METADATA_TEMPLATE_TYPE: {
if (Record.size() != 3)
return error("Invalid record");
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index b1b699765bd..201b4bc34c2 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1017,6 +1017,7 @@ static void WriteDICompileUnit(const DICompileUnit *N,
Record.push_back(VE.getMetadataOrNullID(N->getGlobalVariables().get()));
Record.push_back(VE.getMetadataOrNullID(N->getImportedEntities().get()));
Record.push_back(N->getDWOId());
+ Record.push_back(VE.getMetadataOrNullID(N->getMacros().get()));
Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev);
Record.clear();
@@ -1092,6 +1093,33 @@ static void WriteDINamespace(const DINamespace *N, const ValueEnumerator &VE,
Record.clear();
}
+static void WriteDIMacro(const DIMacro *N, const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(N->getMacinfoType());
+ Record.push_back(N->getLine());
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawValue()));
+
+ Stream.EmitRecord(bitc::METADATA_MACRO, Record, Abbrev);
+ Record.clear();
+}
+
+static void WriteDIMacroFile(const DIMacroFile *N, const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(N->getMacinfoType());
+ Record.push_back(N->getLine());
+ Record.push_back(VE.getMetadataOrNullID(N->getFile()));
+ Record.push_back(VE.getMetadataOrNullID(N->getElements().get()));
+
+ Stream.EmitRecord(bitc::METADATA_MACRO_FILE, Record, Abbrev);
+ Record.clear();
+}
+
static void WriteDIModule(const DIModule *N, const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
OpenPOWER on IntegriCloud