diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -649,6 +649,9 @@ uint16_t Version; uint8_t AddrSize; DwarfFormat Format; + /// True if DWARF v2 output generally uses relocations for references + /// to other .debug_* sections. + bool DwarfUsesRelocationsAcrossSections = false; /// The definition of the size of form DW_FORM_ref_addr depends on the /// version. In DWARF v2 it's the size of an address; after that, it's the diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -17,6 +17,7 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/AsmPrinterHandler.h" #include "llvm/CodeGen/DwarfStringPoolEntry.h" #include "llvm/CodeGen/MachineFunctionPass.h" @@ -231,6 +232,9 @@ /// Returns 4 for DWARF32 and 12 for DWARF64. unsigned int getUnitLengthFieldByteSize() const; + /// Returns information about the byte size of DW_FORM values. + dwarf::FormParams getDwarfFormParams() const; + bool isPositionIndependent() const; /// Return true if assembly output should contain comments. diff --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h --- a/llvm/include/llvm/CodeGen/DIE.h +++ b/llvm/include/llvm/CodeGen/DIE.h @@ -191,7 +191,7 @@ void setValue(uint64_t Val) { Integer = Val; } void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -208,7 +208,7 @@ const MCExpr *getValue() const { return Expr; } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -225,7 +225,7 @@ const MCSymbol *getValue() const { return Label; } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -243,8 +243,8 @@ /// EmitValue - Emit base type reference. void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - /// SizeOf - Determine size of the base type reference in bytes. - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + /// sizeOf - Determine size of the base type reference in bytes. + unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const; void print(raw_ostream &O) const; uint64_t getIndex() const { return Index; } @@ -261,7 +261,7 @@ DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) : LabelHi(Hi), LabelLo(Lo) {} void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -280,7 +280,7 @@ StringRef getString() const { return S.getString(); } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -302,7 +302,7 @@ StringRef getString() const { return S; } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &, dwarf::Form) const; void print(raw_ostream &O) const; }; @@ -321,7 +321,7 @@ DIE &getEntry() const { return *Entry; } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -340,7 +340,7 @@ size_t getValue() const { return Index; } void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -356,7 +356,7 @@ : Addr(Idx), Offset(Hi, Lo) {} void emitValue(const AsmPrinter *AP, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &FormParams, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -506,7 +506,7 @@ void emitValue(const AsmPrinter *AP) const; /// Return the size of a value in bytes. - unsigned SizeOf(const AsmPrinter *AP) const; + unsigned sizeOf(const dwarf::FormParams &FormParams) const; void print(raw_ostream &O) const; void dump() const; @@ -825,12 +825,12 @@ /// properly refer to other DIE objects since all DIEs have calculated their /// offsets. /// - /// \param AP AsmPrinter to use when calculating sizes. + /// \param FormParams Used when calculating sizes. /// \param AbbrevSet the abbreviation used to unique DIE abbreviations. /// \param CUOffset the compile/type unit relative offset in bytes. /// \returns the offset for the DIE that follows this DIE within the /// current compile/type unit. - unsigned computeOffsetsAndAbbrevs(const AsmPrinter *AP, + unsigned computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset); /// Climb up the parent chain to get the compile unit or type unit DIE that @@ -933,9 +933,8 @@ public: DIELoc() = default; - /// ComputeSize - Calculate the size of the location expression. - /// - unsigned ComputeSize(const AsmPrinter *AP) const; + /// Calculate the size of the location expression. + unsigned computeSize(const dwarf::FormParams &FormParams) const; // TODO: move setSize() and Size to DIEValueList. void setSize(unsigned size) { Size = size; } @@ -956,7 +955,7 @@ } void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const; void print(raw_ostream &O) const; }; @@ -970,9 +969,8 @@ public: DIEBlock() = default; - /// ComputeSize - Calculate the size of the location expression. - /// - unsigned ComputeSize(const AsmPrinter *AP) const; + /// Calculate the size of the location expression. + unsigned computeSize(const dwarf::FormParams &FormParams) const; // TODO: move setSize() and Size to DIEValueList. void setSize(unsigned size) { Size = size; } @@ -990,7 +988,7 @@ } void emitValue(const AsmPrinter *Asm, dwarf::Form Form) const; - unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const; + unsigned sizeOf(const dwarf::FormParams &, dwarf::Form Form) const; void print(raw_ostream &O) const; }; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -3649,6 +3649,12 @@ OutStreamer->getContext().getDwarfFormat()); } +dwarf::FormParams AsmPrinter::getDwarfFormParams() const { + return {getDwarfVersion(), uint8_t(getPointerSize()), + OutStreamer->getContext().getDwarfFormat(), + MAI->doesDwarfUseRelocationsAcrossSections()}; +} + unsigned int AsmPrinter::getUnitLengthFieldByteSize() const { return dwarf::getUnitLengthFieldByteSize( OutStreamer->getContext().getDwarfFormat()); diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -274,7 +274,7 @@ } #endif -unsigned DIE::computeOffsetsAndAbbrevs(const AsmPrinter *AP, +unsigned DIE::computeOffsetsAndAbbrevs(const dwarf::FormParams &FormParams, DIEAbbrevSet &AbbrevSet, unsigned CUOffset) { // Unique the abbreviation and fill in the abbreviation number so this DIE @@ -289,7 +289,7 @@ // Add the byte size of all the DIE attribute values. for (const auto &V : values()) - CUOffset += V.SizeOf(AP); + CUOffset += V.sizeOf(FormParams); // Let the children compute their offsets and abbreviation numbers. if (hasChildren()) { @@ -297,7 +297,8 @@ assert(Abbrev.hasChildren() && "Children flag not set"); for (auto &Child : children()) - CUOffset = Child.computeOffsetsAndAbbrevs(AP, AbbrevSet, CUOffset); + CUOffset = + Child.computeOffsetsAndAbbrevs(FormParams, AbbrevSet, CUOffset); // Each child chain is terminated with a zero byte, adjust the offset. CUOffset += sizeof(int8_t); @@ -335,13 +336,13 @@ } } -unsigned DIEValue::SizeOf(const AsmPrinter *AP) const { +unsigned DIEValue::sizeOf(const dwarf::FormParams &FormParams) const { switch (Ty) { case isNone: llvm_unreachable("Expected valid DIEValue"); #define HANDLE_DIEVALUE(T) \ case is##T: \ - return getDIE##T().SizeOf(AP, Form); + return getDIE##T().sizeOf(FormParams, Form); #include "llvm/CodeGen/DIEValue.def" } llvm_unreachable("Unknown DIE kind"); @@ -407,7 +408,8 @@ case dwarf::DW_FORM_strp_sup: case dwarf::DW_FORM_addr: case dwarf::DW_FORM_ref_addr: - Asm->OutStreamer->emitIntValue(Integer, SizeOf(Asm, Form)); + Asm->OutStreamer->emitIntValue(Integer, + sizeOf(Asm->getDwarfFormParams(), Form)); return; case dwarf::DW_FORM_GNU_str_index: case dwarf::DW_FORM_GNU_addr_index: @@ -425,15 +427,12 @@ } } -/// SizeOf - Determine size of integer value in bytes. +/// sizeOf - Determine size of integer value in bytes. /// -unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { - assert(AP && "AsmPrinter is required to set FormParams"); - dwarf::FormParams Params = {AP->getDwarfVersion(), - uint8_t(AP->getPointerSize()), - AP->OutStreamer->getContext().getDwarfFormat()}; - - if (Optional FixedSize = dwarf::getFixedFormByteSize(Form, Params)) +unsigned DIEInteger::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { + if (Optional FixedSize = + dwarf::getFixedFormByteSize(Form, FormParams)) return *FixedSize; switch (Form) { @@ -464,19 +463,20 @@ /// EmitValue - Emit expression value. /// void DIEExpr::emitValue(const AsmPrinter *AP, dwarf::Form Form) const { - AP->emitDebugValue(Expr, SizeOf(AP, Form)); + AP->emitDebugValue(Expr, sizeOf(AP->getDwarfFormParams(), Form)); } /// SizeOf - Determine size of expression value in bytes. /// -unsigned DIEExpr::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEExpr::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_data4: return 4; case dwarf::DW_FORM_data8: return 8; case dwarf::DW_FORM_sec_offset: - return AP->getDwarfOffsetByteSize(); + return FormParams.getDwarfOffsetByteSize(); default: llvm_unreachable("DIE Value form not supported yet"); } @@ -493,12 +493,14 @@ /// void DIELabel::emitValue(const AsmPrinter *AP, dwarf::Form Form) const { bool IsSectionRelative = Form != dwarf::DW_FORM_addr; - AP->emitLabelReference(Label, SizeOf(AP, Form), IsSectionRelative); + AP->emitLabelReference(Label, sizeOf(AP->getDwarfFormParams(), Form), + IsSectionRelative); } -/// SizeOf - Determine size of label value in bytes. +/// sizeOf - Determine size of label value in bytes. /// -unsigned DIELabel::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIELabel::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_data4: return 4; @@ -506,9 +508,9 @@ return 8; case dwarf::DW_FORM_sec_offset: case dwarf::DW_FORM_strp: - return AP->getDwarfOffsetByteSize(); + return FormParams.getDwarfOffsetByteSize(); case dwarf::DW_FORM_addr: - return AP->MAI->getCodePointerSize(); + return FormParams.AddrSize; default: llvm_unreachable("DIE Value form not supported yet"); } @@ -527,7 +529,7 @@ AP->emitULEB128(Offset, nullptr, ULEB128PadSize); } -unsigned DIEBaseTypeRef::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEBaseTypeRef::sizeOf(const dwarf::FormParams &, dwarf::Form) const { return ULEB128PadSize; } @@ -541,19 +543,21 @@ /// EmitValue - Emit delta value. /// void DIEDelta::emitValue(const AsmPrinter *AP, dwarf::Form Form) const { - AP->emitLabelDifference(LabelHi, LabelLo, SizeOf(AP, Form)); + AP->emitLabelDifference(LabelHi, LabelLo, + sizeOf(AP->getDwarfFormParams(), Form)); } /// SizeOf - Determine size of delta value in bytes. /// -unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEDelta::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_data4: return 4; case dwarf::DW_FORM_data8: return 8; case dwarf::DW_FORM_sec_offset: - return AP->getDwarfOffsetByteSize(); + return FormParams.getDwarfOffsetByteSize(); default: llvm_unreachable("DIE Value form not supported yet"); } @@ -592,9 +596,10 @@ } } -/// SizeOf - Determine size of delta value in bytes. +/// sizeOf - Determine size of delta value in bytes. /// -unsigned DIEString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEString::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { // Index of string in symbol table. switch (Form) { case dwarf::DW_FORM_GNU_str_index: @@ -603,11 +608,11 @@ case dwarf::DW_FORM_strx2: case dwarf::DW_FORM_strx3: case dwarf::DW_FORM_strx4: - return DIEInteger(S.getIndex()).SizeOf(AP, Form); + return DIEInteger(S.getIndex()).sizeOf(FormParams, Form); case dwarf::DW_FORM_strp: - if (AP->MAI->doesDwarfUseRelocationsAcrossSections()) - return DIELabel(S.getSymbol()).SizeOf(AP, Form); - return DIEInteger(S.getOffset()).SizeOf(AP, Form); + if (FormParams.DwarfUsesRelocationsAcrossSections) + return DIELabel(S.getSymbol()).sizeOf(FormParams, Form); + return DIEInteger(S.getOffset()).sizeOf(FormParams, Form); default: llvm_unreachable("Expected valid string form"); } @@ -630,7 +635,7 @@ llvm_unreachable("Expected valid string form"); } -unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEInlineString::sizeOf(const dwarf::FormParams &, dwarf::Form) const { // Emit string bytes + NULL byte. return S.size() + 1; } @@ -653,7 +658,8 @@ case dwarf::DW_FORM_ref2: case dwarf::DW_FORM_ref4: case dwarf::DW_FORM_ref8: - AP->OutStreamer->emitIntValue(Entry->getOffset(), SizeOf(AP, Form)); + AP->OutStreamer->emitIntValue(Entry->getOffset(), + sizeOf(AP->getDwarfFormParams(), Form)); return; case dwarf::DW_FORM_ref_udata: @@ -665,11 +671,12 @@ uint64_t Addr = Entry->getDebugSectionOffset(); if (const MCSymbol *SectionSym = Entry->getUnit()->getCrossSectionRelativeBaseAddress()) { - AP->emitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true); + AP->emitLabelPlusOffset(SectionSym, Addr, + sizeOf(AP->getDwarfFormParams(), Form), true); return; } - AP->OutStreamer->emitIntValue(Addr, SizeOf(AP, Form)); + AP->OutStreamer->emitIntValue(Addr, sizeOf(AP->getDwarfFormParams(), Form)); return; } default: @@ -677,7 +684,8 @@ } } -unsigned DIEEntry::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEEntry::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_ref1: return 1; @@ -690,15 +698,7 @@ case dwarf::DW_FORM_ref_udata: return getULEB128Size(Entry->getOffset()); case dwarf::DW_FORM_ref_addr: - if (AP->getDwarfVersion() == 2) - return AP->MAI->getCodePointerSize(); - switch (AP->OutStreamer->getContext().getDwarfFormat()) { - case dwarf::DWARF32: - return 4; - case dwarf::DWARF64: - return 8; - } - llvm_unreachable("Invalid DWARF format"); + return FormParams.getRefAddrByteSize(); default: llvm_unreachable("Improper form for DIE reference"); @@ -714,12 +714,10 @@ // DIELoc Implementation //===----------------------------------------------------------------------===// -/// ComputeSize - calculate the size of the location expression. -/// -unsigned DIELoc::ComputeSize(const AsmPrinter *AP) const { +unsigned DIELoc::computeSize(const dwarf::FormParams &FormParams) const { if (!Size) { for (const auto &V : values()) - Size += V.SizeOf(AP); + Size += V.sizeOf(FormParams); } return Size; @@ -743,9 +741,9 @@ V.emitValue(Asm); } -/// SizeOf - Determine size of location data in bytes. +/// sizeOf - Determine size of location data in bytes. /// -unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIELoc::sizeOf(const dwarf::FormParams &, dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); @@ -766,12 +764,10 @@ // DIEBlock Implementation //===----------------------------------------------------------------------===// -/// ComputeSize - calculate the size of the block. -/// -unsigned DIEBlock::ComputeSize(const AsmPrinter *AP) const { +unsigned DIEBlock::computeSize(const dwarf::FormParams &FormParams) const { if (!Size) { for (const auto &V : values()) - Size += V.SizeOf(AP); + Size += V.sizeOf(FormParams); } return Size; @@ -797,9 +793,9 @@ V.emitValue(Asm); } -/// SizeOf - Determine size of block data in bytes. +/// sizeOf - Determine size of block data in bytes. /// -unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIEBlock::sizeOf(const dwarf::FormParams &, dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_block1: return Size + sizeof(int8_t); case dwarf::DW_FORM_block2: return Size + sizeof(int16_t); @@ -820,22 +816,23 @@ // DIELocList Implementation //===----------------------------------------------------------------------===// -unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { +unsigned DIELocList::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form Form) const { switch (Form) { case dwarf::DW_FORM_loclistx: return getULEB128Size(Index); case dwarf::DW_FORM_data4: - assert(!AP->isDwarf64() && + assert(FormParams.Format != dwarf::DWARF64 && "DW_FORM_data4 is not suitable to emit a pointer to a location list " "in the 64-bit DWARF format"); return 4; case dwarf::DW_FORM_data8: - assert(AP->isDwarf64() && + assert(FormParams.Format == dwarf::DWARF64 && "DW_FORM_data8 is not suitable to emit a pointer to a location list " "in the 32-bit DWARF format"); return 8; case dwarf::DW_FORM_sec_offset: - return AP->getDwarfOffsetByteSize(); + return FormParams.getDwarfOffsetByteSize(); default: llvm_unreachable("DIE Value form not supported yet"); } @@ -860,9 +857,10 @@ // DIEAddrOffset Implementation //===----------------------------------------------------------------------===// -unsigned DIEAddrOffset::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { - return Addr.SizeOf(AP, dwarf::DW_FORM_addrx) + - Offset.SizeOf(AP, dwarf::DW_FORM_data4); +unsigned DIEAddrOffset::sizeOf(const dwarf::FormParams &FormParams, + dwarf::Form) const { + return Addr.sizeOf(FormParams, dwarf::DW_FORM_addrx) + + Offset.sizeOf(FormParams, dwarf::DW_FORM_data4); } /// EmitValue - Emit label value. diff --git a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIEHash.cpp @@ -310,10 +310,10 @@ addULEB128(Attribute); addULEB128(dwarf::DW_FORM_block); if (Value.getType() == DIEValue::isBlock) { - addULEB128(Value.getDIEBlock().ComputeSize(AP)); + addULEB128(Value.getDIEBlock().computeSize(AP->getDwarfFormParams())); hashBlockData(Value.getDIEBlock().values()); } else if (Value.getType() == DIEValue::isLoc) { - addULEB128(Value.getDIELoc().ComputeSize(AP)); + addULEB128(Value.getDIELoc().computeSize(AP->getDwarfFormParams())); hashBlockData(Value.getDIELoc().values()); } else { // We could add the block length, but that would take diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -92,7 +92,8 @@ // Compute the size and offset of a DIE. The offset is relative to start of the // CU. It returns the offset after laying out the DIE. unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) { - return Die.computeOffsetsAndAbbrevs(Asm, Abbrevs, Offset); + return Die.computeOffsetsAndAbbrevs(Asm->getDwarfFormParams(), Abbrevs, + Offset); } void DwarfFile::emitAbbrevs(MCSection *Section) { Abbrevs.Emit(Asm, Section); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -77,7 +77,7 @@ void DIEDwarfExpression::disableTemporaryBuffer() { IsBuffering = false; } unsigned DIEDwarfExpression::getTemporaryBufferSize() { - return TmpDIE.ComputeSize(&AP); + return TmpDIE.computeSize(AP.getDwarfFormParams()); } void DIEDwarfExpression::commitTemporaryBuffer() { OutDIE.takeValues(TmpDIE); } @@ -394,14 +394,14 @@ } void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc) { - Loc->ComputeSize(Asm); + Loc->computeSize(Asm->getDwarfFormParams()); DIELocs.push_back(Loc); // Memoize so we can call the destructor later on. addAttribute(Die, Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc); } void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form, DIEBlock *Block) { - Block->ComputeSize(Asm); + Block->computeSize(Asm->getDwarfFormParams()); DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on. addAttribute(Die, Attribute, Form, Block); } diff --git a/llvm/unittests/CodeGen/DIETest.cpp b/llvm/unittests/CodeGen/DIETest.cpp --- a/llvm/unittests/CodeGen/DIETest.cpp +++ b/llvm/unittests/CodeGen/DIETest.cpp @@ -8,6 +8,7 @@ #include "llvm/CodeGen/DIE.h" #include "TestAsmPrinter.h" +#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/Testing/Support/Error.h" @@ -54,7 +55,7 @@ TEST_P(DIEExprFixture, SizeOf) { DIEExpr Tst(Val); - EXPECT_EQ(Size, Tst.SizeOf(TestPrinter->getAP(), Form)); + EXPECT_EQ(Size, Tst.sizeOf(TestPrinter->getAP()->getDwarfFormParams(), Form)); } TEST_P(DIEExprFixture, EmitValue) { @@ -87,7 +88,7 @@ TEST_P(DIELabelFixture, SizeOf) { DIELabel Tst(Val); - EXPECT_EQ(Size, Tst.SizeOf(TestPrinter->getAP(), Form)); + EXPECT_EQ(Size, Tst.sizeOf(TestPrinter->getAP()->getDwarfFormParams(), Form)); } TEST_P(DIELabelFixture, EmitValue) { @@ -133,7 +134,7 @@ TEST_P(DIEDeltaFixture, SizeOf) { DIEDelta Tst(Hi, Lo); - EXPECT_EQ(Size, Tst.SizeOf(TestPrinter->getAP(), Form)); + EXPECT_EQ(Size, Tst.sizeOf(TestPrinter->getAP()->getDwarfFormParams(), Form)); } TEST_P(DIEDeltaFixture, EmitValue) { @@ -158,7 +159,7 @@ TEST_P(DIELocListFixture, SizeOf) { DIELocList Tst(999); - EXPECT_EQ(Size, Tst.SizeOf(TestPrinter->getAP(), Form)); + EXPECT_EQ(Size, Tst.sizeOf(TestPrinter->getAP()->getDwarfFormParams(), Form)); } INSTANTIATE_TEST_SUITE_P( diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp --- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -47,8 +47,8 @@ //===----------------------------------------------------------------------===// unsigned dwarfgen::DIE::computeSizeAndOffsets(unsigned Offset) { auto &DG = CU->getGenerator(); - return Die->computeOffsetsAndAbbrevs(DG.getAsmPrinter(), DG.getAbbrevSet(), - Offset); + return Die->computeOffsetsAndAbbrevs(DG.getAsmPrinter()->getDwarfFormParams(), + DG.getAbbrevSet(), Offset); } void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form, uint64_t U) { @@ -112,7 +112,7 @@ DIEInteger( (const_cast(static_cast(P)))[I])); - Block->ComputeSize(DG.getAsmPrinter()); + Block->computeSize(DG.getAsmPrinter()->getDwarfFormParams()); Die->addValue(DG.getAllocator(), static_cast(A), Form, Block); }