diff options
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r-- | lib/CodeGen/AsmPrinter/AddressPool.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/AddressPool.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 15 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfExpression.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfFile.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 4 |
7 files changed, 39 insertions, 8 deletions
diff --git a/lib/CodeGen/AsmPrinter/AddressPool.cpp b/lib/CodeGen/AsmPrinter/AddressPool.cpp index 4a226527cb5b..c8305ad9c547 100644 --- a/lib/CodeGen/AsmPrinter/AddressPool.cpp +++ b/lib/CodeGen/AsmPrinter/AddressPool.cpp @@ -24,8 +24,26 @@ unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) { return IterBool.first->second.Number; } + +void AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) { + static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize(); + Asm.OutStreamer->SwitchSection(Section); + + uint64_t Length = sizeof(uint16_t) // version + + sizeof(uint8_t) // address_size + + sizeof(uint8_t) // segment_selector_size + + AddrSize * Pool.size(); // entries + Asm.emitInt32(Length); // TODO: Support DWARF64 format. + Asm.emitInt16(Asm.getDwarfVersion()); + Asm.emitInt8(AddrSize); + Asm.emitInt8(0); // TODO: Support non-zero segment_selector_size. +} + // Emit addresses into the section given. void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) { + if (Asm.getDwarfVersion() >= 5) + emitHeader(Asm, AddrSection); + if (Pool.empty()) return; diff --git a/lib/CodeGen/AsmPrinter/AddressPool.h b/lib/CodeGen/AsmPrinter/AddressPool.h index 5350006bf744..d5008fab5563 100644 --- a/lib/CodeGen/AsmPrinter/AddressPool.h +++ b/lib/CodeGen/AsmPrinter/AddressPool.h @@ -50,6 +50,9 @@ public: bool hasBeenUsed() const { return HasBeenUsed; } void resetUsedFlag() { HasBeenUsed = false; } + +private: + void emitHeader(AsmPrinter &Asm, MCSection *Section); }; } // end namespace llvm diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 8761fae9dd22..500e7a00196f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -364,7 +364,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) else UseSectionsAsReferences = DwarfSectionsAsReferences == Enable; - GenerateTypeUnits = GenerateDwarfTypeUnits; + // Don't generate type units for unsupported object file formats. + GenerateTypeUnits = + A->TM.getTargetTriple().isOSBinFormatELF() && GenerateDwarfTypeUnits; TheAccelTableKind = computeAccelTableKind( DwarfVersion, GenerateTypeUnits, DebuggerTuning, A->TM.getTargetTriple()); @@ -886,8 +888,7 @@ void DwarfDebug::endModule() { emitDebugInfoDWO(); emitDebugAbbrevDWO(); emitDebugLineDWO(); - // Emit DWO addresses. - AddrPool.emit(*Asm, Asm->getObjFileLowering().getDwarfAddrSection()); + emitDebugAddr(); } // Emit info into the dwarf accelerator table sections. @@ -2136,7 +2137,7 @@ void DwarfDebug::emitDebugRanges() { return; } - if (getDwarfVersion() >= 5 && NoRangesPresent()) + if (NoRangesPresent()) return; // Start the dwarf ranges section. @@ -2297,6 +2298,12 @@ void DwarfDebug::emitDebugStrDWO() { OffSec, /* UseRelativeOffsets = */ false); } +// Emit DWO addresses. +void DwarfDebug::emitDebugAddr() { + assert(useSplitDwarf() && "No split dwarf?"); + AddrPool.emit(*Asm, Asm->getObjFileLowering().getDwarfAddrSection()); +} + MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit &CU) { if (!useSplitDwarf()) return nullptr; diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 0c7be5d27dfe..abf2e43b1312 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -447,6 +447,9 @@ class DwarfDebug : public DebugHandlerBase { /// Emit the debug str dwo section. void emitDebugStrDWO(); + /// Emit DWO addresses. + void emitDebugAddr(); + /// Flags to let the linker know we have emitted new style pubnames. Only /// emit it here if we don't have a skeleton CU for split dwarf. void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const; diff --git a/lib/CodeGen/AsmPrinter/DwarfExpression.h b/lib/CodeGen/AsmPrinter/DwarfExpression.h index 952b0d99a95a..0637d952eba4 100644 --- a/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -112,7 +112,7 @@ protected: uint64_t OffsetInBits = 0; unsigned DwarfVersion; - /// Sometimes we need to add a DW_OP_bit_piece to describe a subregister. + /// Sometimes we need to add a DW_OP_bit_piece to describe a subregister. unsigned SubRegisterSizeInBits = 0; unsigned SubRegisterOffsetInBits = 0; diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/lib/CodeGen/AsmPrinter/DwarfFile.cpp index c90bd568162d..049f349b009a 100644 --- a/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -95,6 +95,6 @@ bool DwarfFile::addScopeVariable(LexicalScope *LS, DbgVariable *Var) { } } else { ScopeVars.Locals.push_back(Var); - } + } return true; } diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 43b835b2c4aa..600f4a78fda0 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1182,7 +1182,7 @@ DIE *DwarfUnit::getOrCreateModule(const DIModule *M) { addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath()); if (!M->getISysRoot().empty()) addString(MDie, dwarf::DW_AT_LLVM_isysroot, M->getISysRoot()); - + return &MDie; } @@ -1691,7 +1691,7 @@ void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) { } void DwarfTypeUnit::emitHeader(bool UseOffsets) { - DwarfUnit::emitCommonHeader(UseOffsets, + DwarfUnit::emitCommonHeader(UseOffsets, DD->useSplitDwarf() ? dwarf::DW_UT_split_type : dwarf::DW_UT_type); Asm->OutStreamer->AddComment("Type Signature"); |