Index: lib/CodeGen/AsmPrinter/DIE.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DIE.cpp +++ lib/CodeGen/AsmPrinter/DIE.cpp @@ -42,6 +42,8 @@ // overloads. Otherwise MSVC 2010 thinks this call is ambiguous. ID.AddInteger(unsigned(Attribute)); ID.AddInteger(unsigned(Form)); + if (dwarf::DW_FORM_implicit_const == Form) + ID.AddInteger(Value); } //===----------------------------------------------------------------------===// @@ -107,8 +109,12 @@ O << " " << dwarf::AttributeString(Data[i].getAttribute()) << " " - << dwarf::FormEncodingString(Data[i].getForm()) - << '\n'; + << dwarf::FormEncodingString(Data[i].getForm()); + + if (dwarf::DW_FORM_implicit_const == Data[i].getForm()) + O << " " << Data[i].getValue(); + + O << '\n'; } } Index: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp =================================================================== --- unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -1543,4 +1543,38 @@ EXPECT_EQ(DieMangled, toString(NameOpt, "")); } +TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) { + uint16_t Version = 5; + + const uint8_t AddrSize = sizeof(void *); + initLLVMIfNeeded(); + Triple Triple = getHostTripleForAddrSize(AddrSize); + auto ExpectedDG = dwarfgen::Generator::create(Triple, Version); + if (HandleExpectedError(ExpectedDG)) + return; + dwarfgen::Generator *DG = ExpectedDG.get().get(); + dwarfgen::CompileUnit &CU = DG->addCompileUnit(); + dwarfgen::DIE CUDie = CU.getUnitDIE(); + uint16_t Attr = DW_AT_lo_user; + int64_t Val1 = 42; + int64_t Val2 = 43; + + auto &AbbrevSet = DG->getAbbrevSet(); + auto FirstVal1DIE = CUDie.addChild(DW_TAG_class_type); + FirstVal1DIE.addAttribute(Attr, DW_FORM_implicit_const, Val1); + auto &FirstVal1Abbrev = AbbrevSet.uniqueAbbreviation(FirstVal1DIE.getDIE()); + + auto SecondVal1DIE = CUDie.addChild(DW_TAG_class_type); + SecondVal1DIE.addAttribute(Attr, DW_FORM_implicit_const, Val1); + auto &SecondVal1Abbrev = AbbrevSet.uniqueAbbreviation(SecondVal1DIE.getDIE()); + + EXPECT_EQ(FirstVal1Abbrev.getNumber(), SecondVal1Abbrev.getNumber()); + + auto Val2DIE = CUDie.addChild(DW_TAG_class_type); + Val2DIE.addAttribute(Attr, DW_FORM_implicit_const, Val2); + auto &Val2Abbrev = AbbrevSet.uniqueAbbreviation(Val2DIE.getDIE()); + + EXPECT_NE(FirstVal1Abbrev.getNumber(), Val2Abbrev.getNumber()); +} + } // end anonymous namespace Index: unittests/DebugInfo/DWARF/DwarfGenerator.h =================================================================== --- unittests/DebugInfo/DWARF/DwarfGenerator.h +++ unittests/DebugInfo/DWARF/DwarfGenerator.h @@ -132,6 +132,9 @@ /// Force a DIE to say it has children even when it doesn't. void setForceChildren(); + + /// Get actual DIE object + llvm::DIE &getDIE() { return *Die; } }; /// A DWARF compile unit used to generate DWARF compile/type units.