From 849c7601a03398d2cba5325d778eb0bed63252f2 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 21 May 2015 20:37:30 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237949 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DIBuilder.h | 13 ++-- include/llvm/IR/DebugInfoMetadata.h | 53 +++++++++-------- lib/AsmParser/LLParser.cpp | 7 ++- lib/Bitcode/Reader/BitcodeReader.cpp | 5 +- lib/Bitcode/Writer/BitcodeWriter.cpp | 1 + lib/IR/AsmWriter.cpp | 1 + lib/IR/DIBuilder.cpp | 4 +- lib/IR/DebugInfoMetadata.cpp | 7 ++- lib/IR/LLVMContextImpl.h | 12 ++-- test/Assembler/mdcompileunit.ll | 6 +- test/Bitcode/DICompileUnit-no-DWOId.ll | 9 +++ test/Bitcode/DICompileUnit-no-DWOId.ll.bc | Bin 0 -> 424 bytes unittests/IR/MetadataTest.cpp | 69 +++++++++++++--------- 13 files changed, 109 insertions(+), 78 deletions(-) create mode 100644 test/Bitcode/DICompileUnit-no-DWOId.ll create mode 100644 test/Bitcode/DICompileUnit-no-DWOId.ll.bc diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index 68fb59b2019..997113191d1 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -95,6 +95,7 @@ namespace llvm { /// @param SplitName The name of the file that we'll split debug info out /// into. /// @param Kind The kind of debug information to generate. + /// @param DWOId The DWOId if this is a split skeleton compile unit. /// @param EmitDebugInfo A boolean flag which indicates whether debug /// information should be written to the final /// output or not. When this is false, debug @@ -104,12 +105,12 @@ namespace llvm { /// source location information in the back end /// without actually changing the output (e.g., /// when using optimization remarks). - DICompileUnit *createCompileUnit(unsigned Lang, StringRef File, - StringRef Dir, StringRef Producer, - bool isOptimized, StringRef Flags, - unsigned RV, StringRef SplitName = "", - DebugEmissionKind Kind = FullDebug, - bool EmitDebugInfo = true); + DICompileUnit * + createCompileUnit(unsigned Lang, StringRef File, StringRef Dir, + StringRef Producer, bool isOptimized, StringRef Flags, + unsigned RV, StringRef SplitName = StringRef(), + DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0, + bool EmitDebugInfo = true); /// createFile - Create a file descriptor to hold debugging information /// for a file. diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 2be5e9349e1..0125de5d40f 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -971,13 +971,15 @@ class DICompileUnit : public DIScope { bool IsOptimized; unsigned RuntimeVersion; unsigned EmissionKind; + uint64_t DWOId; DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage, bool IsOptimized, unsigned RuntimeVersion, - unsigned EmissionKind, ArrayRef Ops) + unsigned EmissionKind, uint64_t DWOId, ArrayRef Ops) : DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops), SourceLanguage(SourceLanguage), IsOptimized(IsOptimized), - RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind) {} + RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind), + DWOId(DWOId) {} ~DICompileUnit() = default; static DICompileUnit * @@ -987,14 +989,15 @@ class DICompileUnit : public DIScope { unsigned EmissionKind, DICompositeTypeArray EnumTypes, DITypeArray RetainedTypes, DISubprogramArray Subprograms, DIGlobalVariableArray GlobalVariables, - DIImportedEntityArray ImportedEntities, StorageType Storage, - bool ShouldCreate = true) { - return getImpl( - Context, SourceLanguage, File, getCanonicalMDString(Context, Producer), - IsOptimized, getCanonicalMDString(Context, Flags), RuntimeVersion, - getCanonicalMDString(Context, SplitDebugFilename), EmissionKind, - EnumTypes.get(), RetainedTypes.get(), Subprograms.get(), - GlobalVariables.get(), ImportedEntities.get(), Storage, ShouldCreate); + DIImportedEntityArray ImportedEntities, uint64_t DWOId, + StorageType Storage, bool ShouldCreate = true) { + return getImpl(Context, SourceLanguage, File, + getCanonicalMDString(Context, Producer), IsOptimized, + getCanonicalMDString(Context, Flags), RuntimeVersion, + getCanonicalMDString(Context, SplitDebugFilename), + EmissionKind, EnumTypes.get(), RetainedTypes.get(), + Subprograms.get(), GlobalVariables.get(), + ImportedEntities.get(), DWOId, Storage, ShouldCreate); } static DICompileUnit * getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File, @@ -1002,7 +1005,7 @@ class DICompileUnit : public DIScope { unsigned RuntimeVersion, MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes, Metadata *Subprograms, Metadata *GlobalVariables, - Metadata *ImportedEntities, StorageType Storage, + Metadata *ImportedEntities, uint64_t DWOId, StorageType Storage, bool ShouldCreate = true); TempDICompileUnit cloneImpl() const { @@ -1010,7 +1013,7 @@ class DICompileUnit : public DIScope { getContext(), getSourceLanguage(), getFile(), getProducer(), isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(), getEmissionKind(), getEnumTypes(), getRetainedTypes(), getSubprograms(), - getGlobalVariables(), getImportedEntities()); + getGlobalVariables(), getImportedEntities(), DWOId); } public: @@ -1021,22 +1024,21 @@ public: DICompositeTypeArray EnumTypes, DITypeArray RetainedTypes, DISubprogramArray Subprograms, DIGlobalVariableArray GlobalVariables, - DIImportedEntityArray ImportedEntities), + DIImportedEntityArray ImportedEntities, uint64_t DWOId), (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)) - DEFINE_MDNODE_GET(DICompileUnit, - (unsigned SourceLanguage, Metadata *File, - MDString *Producer, bool IsOptimized, MDString *Flags, - unsigned RuntimeVersion, MDString *SplitDebugFilename, - unsigned EmissionKind, Metadata *EnumTypes, - Metadata *RetainedTypes, Metadata *Subprograms, - Metadata *GlobalVariables, Metadata *ImportedEntities), - (SourceLanguage, File, Producer, IsOptimized, Flags, - RuntimeVersion, SplitDebugFilename, EmissionKind, - EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)) + ImportedEntities, DWOId)) + DEFINE_MDNODE_GET( + DICompileUnit, + (unsigned SourceLanguage, Metadata *File, MDString *Producer, + bool IsOptimized, MDString *Flags, unsigned RuntimeVersion, + MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes, + Metadata *RetainedTypes, Metadata *Subprograms, + Metadata *GlobalVariables, Metadata *ImportedEntities, uint64_t DWOId), + (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, + GlobalVariables, ImportedEntities, DWOId)) TempDICompileUnit clone() const { return cloneImpl(); } @@ -1062,6 +1064,7 @@ public: DIImportedEntityArray getImportedEntities() const { return cast_or_null(getRawImportedEntities()); } + unsigned getDWOId() const { return DWOId; } MDString *getRawProducer() const { return getOperandAs(1); } MDString *getRawFlags() const { return getOperandAs(2); } diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index ef464c339f7..d3c8ffd2fef 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -3547,7 +3547,7 @@ bool LLParser::ParseDIFile(MDNode *&Result, bool IsDistinct) { /// isOptimized: true, flags: "-O2", runtimeVersion: 1, /// splitDebugFilename: "abc.debug", emissionKind: 1, /// enums: !1, retainedTypes: !2, subprograms: !3, -/// globals: !4, imports: !5) +/// globals: !4, imports: !5, dwoId: 0x0abcd) bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) { #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ REQUIRED(language, DwarfLangField, ); \ @@ -3562,7 +3562,8 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) { OPTIONAL(retainedTypes, MDField, ); \ OPTIONAL(subprograms, MDField, ); \ OPTIONAL(globals, MDField, ); \ - OPTIONAL(imports, MDField, ); + OPTIONAL(imports, MDField, ); \ + OPTIONAL(dwoId, MDUnsignedField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS @@ -3571,7 +3572,7 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) { isOptimized.Val, flags.Val, runtimeVersion.Val, splitDebugFilename.Val, emissionKind.Val, enums.Val, retainedTypes.Val, subprograms.Val, globals.Val, - imports.Val)); + imports.Val, dwoId.Val)); return false; } diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index bba29172a28..6eef594eaf1 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/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/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 199663d1bfd..3a539e12926 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/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(); diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 304221af400..1089cb58218 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -1624,6 +1624,7 @@ static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N, Printer.printMetadata("subprograms", N->getRawSubprograms()); Printer.printMetadata("globals", N->getRawGlobalVariables()); Printer.printMetadata("imports", N->getRawImportedEntities()); + Printer.printInt("dwoId", N->getDWOId()); Out << ")"; } diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 3baa4680905..b1925ea5c48 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -125,7 +125,7 @@ static DIScope *getNonCompileUnitScope(DIScope *N) { DICompileUnit *DIBuilder::createCompileUnit( unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName, - DebugEmissionKind Kind, bool EmitDebugInfo) { + DebugEmissionKind Kind, uint64_t DWOId, bool EmitDebugInfo) { assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) || (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) && @@ -147,7 +147,7 @@ DICompileUnit *DIBuilder::createCompileUnit( VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer, isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(), TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(), - TempImportedModules.get()); + TempImportedModules.get(), DWOId); // Create a named metadata so that it is easier to find cu in a module. // Note that we only generate this when the caller wants to actually diff --git a/lib/IR/DebugInfoMetadata.cpp b/lib/IR/DebugInfoMetadata.cpp index 85335d547b1..8b9857d373b 100644 --- a/lib/IR/DebugInfoMetadata.cpp +++ b/lib/IR/DebugInfoMetadata.cpp @@ -311,7 +311,8 @@ DICompileUnit *DICompileUnit::getImpl( unsigned RuntimeVersion, MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes, Metadata *Subprograms, Metadata *GlobalVariables, - Metadata *ImportedEntities, StorageType Storage, bool ShouldCreate) { + Metadata *ImportedEntities, uint64_t DWOId, + StorageType Storage, bool ShouldCreate) { assert(isCanonical(Producer) && "Expected canonical MDString"); assert(isCanonical(Flags) && "Expected canonical MDString"); assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString"); @@ -319,13 +320,13 @@ DICompileUnit *DICompileUnit::getImpl( DICompileUnit, (SourceLanguage, File, getString(Producer), IsOptimized, getString(Flags), RuntimeVersion, getString(SplitDebugFilename), EmissionKind, EnumTypes, - RetainedTypes, Subprograms, GlobalVariables, ImportedEntities)); + RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId)); Metadata *Ops[] = {File, Producer, Flags, SplitDebugFilename, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, ImportedEntities}; DEFINE_GETIMPL_STORE( DICompileUnit, - (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind), Ops); + (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind, DWOId), Ops); } DISubprogram *DILocalScope::getSubprogram() const { diff --git a/lib/IR/LLVMContextImpl.h b/lib/IR/LLVMContextImpl.h index 95292509f50..f81db607770 100644 --- a/lib/IR/LLVMContextImpl.h +++ b/lib/IR/LLVMContextImpl.h @@ -472,19 +472,20 @@ template <> struct MDNodeKeyImpl { Metadata *Subprograms; Metadata *GlobalVariables; Metadata *ImportedEntities; + uint64_t DWOId; MDNodeKeyImpl(unsigned SourceLanguage, Metadata *File, StringRef Producer, bool IsOptimized, StringRef Flags, unsigned RuntimeVersion, StringRef SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes, Metadata *Subprograms, Metadata *GlobalVariables, - Metadata *ImportedEntities) + Metadata *ImportedEntities, uint64_t DWOId) : SourceLanguage(SourceLanguage), File(File), Producer(Producer), IsOptimized(IsOptimized), Flags(Flags), RuntimeVersion(RuntimeVersion), SplitDebugFilename(SplitDebugFilename), EmissionKind(EmissionKind), EnumTypes(EnumTypes), RetainedTypes(RetainedTypes), Subprograms(Subprograms), GlobalVariables(GlobalVariables), - ImportedEntities(ImportedEntities) {} + ImportedEntities(ImportedEntities), DWOId(DWOId) {} MDNodeKeyImpl(const DICompileUnit *N) : SourceLanguage(N->getSourceLanguage()), File(N->getRawFile()), Producer(N->getProducer()), IsOptimized(N->isOptimized()), @@ -494,7 +495,7 @@ template <> struct MDNodeKeyImpl { RetainedTypes(N->getRawRetainedTypes()), Subprograms(N->getRawSubprograms()), GlobalVariables(N->getRawGlobalVariables()), - ImportedEntities(N->getRawImportedEntities()) {} + ImportedEntities(N->getRawImportedEntities()), DWOId(N->getDWOId()) {} bool isKeyOf(const DICompileUnit *RHS) const { return SourceLanguage == RHS->getSourceLanguage() && @@ -507,13 +508,14 @@ template <> struct MDNodeKeyImpl { RetainedTypes == RHS->getRawRetainedTypes() && Subprograms == RHS->getRawSubprograms() && GlobalVariables == RHS->getRawGlobalVariables() && - ImportedEntities == RHS->getRawImportedEntities(); + ImportedEntities == RHS->getRawImportedEntities() && + DWOId == RHS->getDWOId(); } unsigned getHashValue() const { return hash_combine(SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities); + ImportedEntities, DWOId); } }; diff --git a/test/Assembler/mdcompileunit.ll b/test/Assembler/mdcompileunit.ll index 9445c80e76b..dc136f0b83e 100644 --- a/test/Assembler/mdcompileunit.ll +++ b/test/Assembler/mdcompileunit.ll @@ -12,17 +12,17 @@ !5 = distinct !{} !6 = distinct !{} -; CHECK: !7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6) +; CHECK: !7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6, dwoId: 42) !7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, - globals: !5, imports: !6) + globals: !5, imports: !6, dwoId: 42) !8 = !DICompileUnit(language: 12, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, - globals: !5, imports: !6) + globals: !5, imports: !6, dwoId: 42) ; CHECK: !8 = !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: 0) !9 = !DICompileUnit(language: 12, file: !1, producer: "", diff --git a/test/Bitcode/DICompileUnit-no-DWOId.ll b/test/Bitcode/DICompileUnit-no-DWOId.ll new file mode 100644 index 00000000000..4771c37264f --- /dev/null +++ b/test/Bitcode/DICompileUnit-no-DWOId.ll @@ -0,0 +1,9 @@ +; The input uses the older (r236428) form without a dwoId field. This should +; default to 0, which is not displayed at all in the textual representation. +; +; RUN: llvm-dis %s.bc -o - | FileCheck %s +; CHECK: !DICompileUnit +; CHECK-NOT: dwoId: +!named = !{!0} +!0 = !DICompileUnit(language: 12, file: !1) +!1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir") diff --git a/test/Bitcode/DICompileUnit-no-DWOId.ll.bc b/test/Bitcode/DICompileUnit-no-DWOId.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..1a3c99b5806b9a3d7178d1a416b93776aa94cd47 GIT binary patch literal 424 zcmZ>AK5$Qwhk+rTfq{X$Nr8b0NDBiod!zD1#}h1`Yyw7>lNeigR9QJBX-nBhvxML(_Z*kwf%^f-G&H_e`mO#D(K(|A{mICffhnYGALdU@x9g$n%VW|E&Pumj*s#9w)g&2W8JKlu0vS z1uJWoKErH#!r8Wm+4f9DPe}oLH3xg8M|(j5dsP8*Sw(w+Lc8P{LB2N=_#PVY=Na%n z{=oMkfX`Uqi0nN@nH!3-hZ5z|3_7j%G+SSAw%o#Ov!~gnh1vSd2a&P__Ua6F^NjW) zAlcAfFrmF5fxS$Fz3c}o(Ae^Z_IQr=LW%aG8SRxb8g<@%;CuIg@9P1+H(>7p00U%% AnE(I) literal 0 HcmV?d00001 diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index baba3e5bc52..6994e2133f6 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -1294,10 +1294,11 @@ TEST_F(DICompileUnitTest, get) { MDTuple *Subprograms = getTuple(); MDTuple *GlobalVariables = getTuple(); MDTuple *ImportedEntities = getTuple(); + uint64_t DWOId = 0xc0ffee; auto *N = DICompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, Subprograms, GlobalVariables, ImportedEntities); + RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId); EXPECT_EQ(dwarf::DW_TAG_compile_unit, N->getTag()); EXPECT_EQ(SourceLanguage, N->getSourceLanguage()); @@ -1313,74 +1314,83 @@ TEST_F(DICompileUnitTest, get) { EXPECT_EQ(Subprograms, N->getSubprograms().get()); EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get()); EXPECT_EQ(ImportedEntities, N->getImportedEntities().get()); + EXPECT_EQ(DWOId, N->getDWOId()); EXPECT_EQ(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage + 1, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, getFile(), Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, "other", IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, !IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, "other", RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion + 1, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); - EXPECT_NE(N, - DICompileUnit::get(Context, SourceLanguage, File, Producer, - IsOptimized, Flags, RuntimeVersion, "other", - EmissionKind, EnumTypes, RetainedTypes, - Subprograms, GlobalVariables, ImportedEntities)); + ImportedEntities, DWOId)); + EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, "other", + EmissionKind, EnumTypes, RetainedTypes, + Subprograms, GlobalVariables, + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind + 1, EnumTypes, RetainedTypes, Subprograms, - GlobalVariables, ImportedEntities)); + GlobalVariables, ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, getTuple(), RetainedTypes, Subprograms, GlobalVariables, - ImportedEntities)); - EXPECT_NE(N, DICompileUnit::get( - Context, SourceLanguage, File, Producer, IsOptimized, Flags, - RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - getTuple(), Subprograms, GlobalVariables, ImportedEntities)); + ImportedEntities, DWOId)); + EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, + getTuple(), Subprograms, GlobalVariables, + ImportedEntities, DWOId)); EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, getTuple(), GlobalVariables, - ImportedEntities)); - EXPECT_NE(N, DICompileUnit::get( - Context, SourceLanguage, File, Producer, IsOptimized, Flags, - RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, Subprograms, getTuple(), ImportedEntities)); - EXPECT_NE(N, DICompileUnit::get( - Context, SourceLanguage, File, Producer, IsOptimized, Flags, - RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, Subprograms, GlobalVariables, getTuple())); + ImportedEntities, DWOId)); + EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, + RetainedTypes, Subprograms, getTuple(), + ImportedEntities, DWOId)); + EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, + RetainedTypes, Subprograms, GlobalVariables, + getTuple(), DWOId)); + EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer, + IsOptimized, Flags, RuntimeVersion, + SplitDebugFilename, EmissionKind, EnumTypes, + RetainedTypes, Subprograms, GlobalVariables, + ImportedEntities, DWOId + 1)); TempDICompileUnit Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); @@ -1398,10 +1408,11 @@ TEST_F(DICompileUnitTest, replaceArrays) { MDTuple *EnumTypes = MDTuple::getDistinct(Context, None); MDTuple *RetainedTypes = MDTuple::getDistinct(Context, None); MDTuple *ImportedEntities = MDTuple::getDistinct(Context, None); + uint64_t DWOId = 0xc0ffee; auto *N = DICompileUnit::get( Context, SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes, - RetainedTypes, nullptr, nullptr, ImportedEntities); + RetainedTypes, nullptr, nullptr, ImportedEntities, DWOId); auto *Subprograms = MDTuple::getDistinct(Context, None); EXPECT_EQ(nullptr, N->getSubprograms().get());