From 1f599f9f653c92f38b9d3784a2dfd8a118942650 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 21 May 2015 20:37:30 +0000 Subject: IR / debug info: Add a DWOId field to DICompileUnit, so DWARF skeleton CUs can be expression in IR. A skeleton CU is a (typically empty) DW_TAG_compile_unit that has a DW_AT_(GNU)_dwo_name and a DW_AT_(GNU)_dwo_id attribute. It is used to refer to external debug info. This is a prerequisite for clang module debugging as discussed in http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/040076.html. In order to refer to external types stored in split DWARF (dwo) objects, such as clang modules, we need to emit skeleton CUs, which identify the dwarf object (i.e., the clang module) by filename (the SplitDebugFilename) and a hash value, the dwo_id. This patch only contains the IR changes. The idea is that a CUs with a non-zero dwo_id field will be emitted together with a DW_AT_GNU_dwo_name and DW_AT_GNU_dwo_id attribute. http://reviews.llvm.org/D9488 rdar://problem/20091852 llvm-svn: 237949 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 5 +++-- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index bba29172a28..6eef594eaf1 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1844,7 +1844,7 @@ std::error_code BitcodeReader::ParseMetadata() { break; } case bitc::METADATA_COMPILE_UNIT: { - if (Record.size() != 14) + if (Record.size() < 14 || Record.size() > 15) return Error("Invalid record"); MDValueList.AssignValue( @@ -1855,7 +1855,8 @@ std::error_code BitcodeReader::ParseMetadata() { getMDString(Record[7]), Record[8], getMDOrNull(Record[9]), getMDOrNull(Record[10]), getMDOrNull(Record[11]), getMDOrNull(Record[12]), - getMDOrNull(Record[13]))), + getMDOrNull(Record[13]), + Record.size() == 14 ? 0 : Record[14])), NextMDValueNo++); break; } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 199663d1bfd..3a539e12926 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -949,6 +949,7 @@ static void WriteDICompileUnit(const DICompileUnit *N, Record.push_back(VE.getMetadataOrNullID(N->getSubprograms().get())); Record.push_back(VE.getMetadataOrNullID(N->getGlobalVariables().get())); Record.push_back(VE.getMetadataOrNullID(N->getImportedEntities().get())); + Record.push_back(N->getDWOId()); Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev); Record.clear(); -- cgit v1.2.3