diff options
Diffstat (limited to 'llvm/lib/DWARFLinkerParallel')
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp | 131 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h | 274 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h | 156 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp | 46 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h | 319 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h | 186 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/OutputSections.cpp | 36 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/OutputSections.h | 67 | ||||
| -rw-r--r-- | llvm/lib/DWARFLinkerParallel/StringPool.cpp | 9 |
10 files changed, 1232 insertions, 4 deletions
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp new file mode 100644 index 000000000000..50909c0ba669 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp @@ -0,0 +1,131 @@ +//===- DWARFEmitterImpl.cpp -----------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "DWARFEmitterImpl.h" +#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCObjectWriter.h" +#include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCTargetOptions.h" +#include "llvm/MC/MCTargetOptionsCommandFlags.h" +#include "llvm/MC/TargetRegistry.h" +#include "llvm/Support/FormattedStream.h" + +namespace llvm { +namespace dwarflinker_parallel { + +Error DwarfEmitterImpl::init(Triple TheTriple, + StringRef Swift5ReflectionSegmentName) { + std::string ErrorStr; + std::string TripleName; + + // Get the target. + const Target *TheTarget = + TargetRegistry::lookupTarget(TripleName, TheTriple, ErrorStr); + if (!TheTarget) + return createStringError(std::errc::invalid_argument, ErrorStr.c_str()); + TripleName = TheTriple.getTriple(); + + // Create all the MC Objects. + MRI.reset(TheTarget->createMCRegInfo(TripleName)); + if (!MRI) + return createStringError(std::errc::invalid_argument, + "no register info for target %s", + TripleName.c_str()); + + MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags(); + MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions)); + if (!MAI) + return createStringError(std::errc::invalid_argument, + "no asm info for target %s", TripleName.c_str()); + + MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, "", "")); + if (!MSTI) + return createStringError(std::errc::invalid_argument, + "no subtarget info for target %s", + TripleName.c_str()); + + MC.reset(new MCContext(TheTriple, MAI.get(), MRI.get(), MSTI.get(), nullptr, + nullptr, true, Swift5ReflectionSegmentName)); + MOFI.reset(TheTarget->createMCObjectFileInfo(*MC, /*PIC=*/false, false)); + MC->setObjectFileInfo(MOFI.get()); + + MAB = TheTarget->createMCAsmBackend(*MSTI, *MRI, MCOptions); + if (!MAB) + return createStringError(std::errc::invalid_argument, + "no asm backend for target %s", + TripleName.c_str()); + + MII.reset(TheTarget->createMCInstrInfo()); + if (!MII) + return createStringError(std::errc::invalid_argument, + "no instr info info for target %s", + TripleName.c_str()); + + MCE = TheTarget->createMCCodeEmitter(*MII, *MC); + if (!MCE) + return createStringError(std::errc::invalid_argument, + "no code emitter for target %s", + TripleName.c_str()); + + switch (OutFileType) { + case DWARFLinker::OutputFileType::Assembly: { + MIP = TheTarget->createMCInstPrinter(TheTriple, MAI->getAssemblerDialect(), + *MAI, *MII, *MRI); + MS = TheTarget->createAsmStreamer( + *MC, std::make_unique<formatted_raw_ostream>(OutFile), true, true, MIP, + std::unique_ptr<MCCodeEmitter>(MCE), std::unique_ptr<MCAsmBackend>(MAB), + true); + break; + } + case DWARFLinker::OutputFileType::Object: { + MS = TheTarget->createMCObjectStreamer( + TheTriple, *MC, std::unique_ptr<MCAsmBackend>(MAB), + MAB->createObjectWriter(OutFile), std::unique_ptr<MCCodeEmitter>(MCE), + *MSTI, MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible, + /*DWARFMustBeAtTheEnd*/ false); + break; + } + } + + if (!MS) + return createStringError(std::errc::invalid_argument, + "no object streamer for target %s", + TripleName.c_str()); + + // Finally create the AsmPrinter we'll use to emit the DIEs. + TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(), + std::nullopt)); + if (!TM) + return createStringError(std::errc::invalid_argument, + "no target machine for target %s", + TripleName.c_str()); + + Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr<MCStreamer>(MS))); + if (!Asm) + return createStringError(std::errc::invalid_argument, + "no asm printer for target %s", + TripleName.c_str()); + Asm->setDwarfUsesRelocationsAcrossSections(false); + + RangesSectionSize = 0; + RngListsSectionSize = 0; + LocSectionSize = 0; + LocListsSectionSize = 0; + LineSectionSize = 0; + FrameSectionSize = 0; + DebugInfoSectionSize = 0; + MacInfoSectionSize = 0; + MacroSectionSize = 0; + + return Error::success(); +} + +} // end of namespace dwarflinker_parallel +} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h new file mode 100644 index 000000000000..d07397a30419 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h @@ -0,0 +1,274 @@ +//===- DwarfEmitterImpl.h ---------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H +#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H + +#include "DWARFLinkerCompileUnit.h" +#include "llvm/BinaryFormat/Swift.h" +#include "llvm/CodeGen/AccelTable.h" +#include "llvm/CodeGen/AsmPrinter.h" +#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "llvm/DWARFLinkerParallel/StringTable.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/Target/TargetMachine.h" + +namespace llvm { + +/// User of DwarfEmitterImpl should call initialization code +/// for AsmPrinter: +/// +/// InitializeAllTargetInfos(); +/// InitializeAllTargetMCs(); +/// InitializeAllTargets(); +/// InitializeAllAsmPrinters(); + +template <typename DataT> class AccelTable; +class MCCodeEmitter; +class DWARFDebugMacro; + +namespace dwarflinker_parallel { + +struct UnitStartSymbol { + unsigned UnitID = 0; + MCSymbol *Symbol = 0; +}; +using UnitStartSymbolsTy = SmallVector<UnitStartSymbol>; +using Offset2UnitMapTy = DenseMap<uint64_t, CompileUnit *>; + +struct RangeAttrPatch; +struct LocAttrPatch; + +/// The Dwarf emission logic. +/// +/// All interactions with the MC layer that is used to build the debug +/// information binary representation are handled in this class. +class DwarfEmitterImpl : public ExtraDwarfEmitter { +public: + DwarfEmitterImpl(DWARFLinker::OutputFileType OutFileType, + raw_pwrite_stream &OutFile, + std::function<StringRef(StringRef Input)> Translator, + DWARFLinker::MessageHandlerTy Warning) + : OutFile(OutFile), OutFileType(OutFileType), Translator(Translator), + WarningHandler(Warning) {} + + Error init(Triple TheTriple, StringRef Swift5ReflectionSegmentName); + + /// Dump the file to the disk. + void finish() override { MS->finish(); } + + AsmPrinter &getAsmPrinter() const override { return *Asm; } + + /// Set the current output section to debug_info and change + /// the MC Dwarf version to \p DwarfVersion. + void switchToDebugInfoSection(unsigned DwarfVersion) {} + + /// Emit the swift_ast section stored in \p Buffer. + void emitSwiftAST(StringRef Buffer) override {} + + /// Emit the swift reflection section stored in \p Buffer. + void emitSwiftReflectionSection( + llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind, + StringRef Buffer, uint32_t Alignment, uint32_t Size) override {} + + void emitPaperTrailWarningsDie(DIE &Die) {} + + void emitSectionContents(StringRef SecData, StringRef SecName) override {} + + MCSymbol *emitTempSym(StringRef SecName, StringRef SymName) override { + return nullptr; + } + + void emitAbbrevs(const SmallVector<std::unique_ptr<DIEAbbrev>> &Abbrevs, + unsigned DwarfVersion) {} + + void emitStrings(const StringTable &Strings) {} + + void emitLineStrings(const StringTable &Strings) {} + + void emitDebugNames(AccelTable<DWARF5AccelTableStaticData> &, + UnitStartSymbolsTy &UnitOffsets) {} + + void emitAppleNamespaces(AccelTable<AppleAccelTableStaticOffsetData> &) {} + + void emitAppleNames(AccelTable<AppleAccelTableStaticOffsetData> &) {} + + void emitAppleObjc(AccelTable<AppleAccelTableStaticOffsetData> &) {} + + void emitAppleTypes(AccelTable<AppleAccelTableStaticTypeData> &) {} + + MCSymbol *emitDwarfDebugRangeListHeader(const CompileUnit &Unit) { + return nullptr; + } + + void emitDwarfDebugRangeListFragment(const CompileUnit &Unit, + const AddressRanges &LinkedRanges, + RangeAttrPatch &Patch) {} + + void emitDwarfDebugRangeListFooter(const CompileUnit &Unit, + MCSymbol *EndLabel) {} + + MCSymbol *emitDwarfDebugLocListHeader(const CompileUnit &Unit) { + return nullptr; + } + + void emitDwarfDebugLocListFragment( + const CompileUnit &Unit, + const DWARFLocationExpressionsVector &LinkedLocationExpression, + LocAttrPatch &Patch) {} + + void emitDwarfDebugLocListFooter(const CompileUnit &Unit, + MCSymbol *EndLabel) {} + + void emitDwarfDebugArangesTable(const CompileUnit &Unit, + const AddressRanges &LinkedRanges) {} + + void translateLineTable(DataExtractor LineData, uint64_t Offset) {} + + void emitLineTableForUnit(MCDwarfLineTableParams Params, + StringRef PrologueBytes, unsigned MinInstLength, + std::vector<DWARFDebugLine::Row> &Rows, + unsigned AdddressSize) {} + + void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable, + const CompileUnit &Unit, const StringTable &Strings, + const StringTable &LineTableStrings) {} + + void emitPubNamesForUnit(const CompileUnit &Unit) {} + + void emitPubTypesForUnit(const CompileUnit &Unit) {} + + void emitCIE(StringRef CIEBytes) {} + + void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, + StringRef Bytes) {} + + void emitCompileUnitHeader(CompileUnit &Unit, unsigned DwarfVersion) {} + + void emitDIE(DIE &Die) {} + + void emitMacroTables(DWARFContext *Context, + const Offset2UnitMapTy &UnitMacroMap, + StringTable &Strings) {} + + /// Returns size of generated .debug_line section. + uint64_t getDebugLineSectionSize() const { return LineSectionSize; } + + /// Returns size of generated .debug_frame section. + uint64_t getDebugFrameSectionSize() const { return FrameSectionSize; } + + /// Returns size of generated .debug_ranges section. + uint64_t getDebugRangesSectionSize() const { return RangesSectionSize; } + + /// Returns size of generated .debug_rnglists section. + uint64_t getDebugRngListsSectionSize() const { return RngListsSectionSize; } + + /// Returns size of generated .debug_info section. + uint64_t getDebugInfoSectionSize() const { return DebugInfoSectionSize; } + + /// Returns size of generated .debug_macinfo section. + uint64_t getDebugMacInfoSectionSize() const { return MacInfoSectionSize; } + + /// Returns size of generated .debug_macro section. + uint64_t getDebugMacroSectionSize() const { return MacroSectionSize; } + + /// Returns size of generated .debug_loc section. + uint64_t getDebugLocSectionSize() const { return LocSectionSize; } + + /// Returns size of generated .debug_loclists section. + uint64_t getDebugLocListsSectionSize() const { return LocListsSectionSize; } + +private: + inline void warn(const Twine &Warning, StringRef Context = "") { + if (WarningHandler) + WarningHandler(Warning, Context, nullptr); + } + + void emitMacroTableImpl(const DWARFDebugMacro *MacroTable, + const Offset2UnitMapTy &UnitMacroMap, + StringPool &StringPool, uint64_t &OutOffset) {} + + /// Emit piece of .debug_ranges for \p LinkedRanges. + void emitDwarfDebugRangesTableFragment(const CompileUnit &Unit, + const AddressRanges &LinkedRanges, + RangeAttrPatch &Patch) {} + + /// Emit piece of .debug_rnglists for \p LinkedRanges. + void emitDwarfDebugRngListsTableFragment(const CompileUnit &Unit, + const AddressRanges &LinkedRanges, + RangeAttrPatch &Patch) {} + + /// Emit piece of .debug_loc for \p LinkedRanges. + void emitDwarfDebugLocTableFragment( + const CompileUnit &Unit, + const DWARFLocationExpressionsVector &LinkedLocationExpression, + LocAttrPatch &Patch) {} + + /// Emit piece of .debug_loclists for \p LinkedRanges. + void emitDwarfDebugLocListsTableFragment( + const CompileUnit &Unit, + const DWARFLocationExpressionsVector &LinkedLocationExpression, + LocAttrPatch &Patch) {} + + /// \defgroup MCObjects MC layer objects constructed by the streamer + /// @{ + std::unique_ptr<MCRegisterInfo> MRI; + std::unique_ptr<MCAsmInfo> MAI; + std::unique_ptr<MCObjectFileInfo> MOFI; + std::unique_ptr<MCContext> MC; + MCAsmBackend *MAB; // Owned by MCStreamer + std::unique_ptr<MCInstrInfo> MII; + std::unique_ptr<MCSubtargetInfo> MSTI; + MCInstPrinter *MIP; // Owned by AsmPrinter + MCCodeEmitter *MCE; // Owned by MCStreamer + MCStreamer *MS; // Owned by AsmPrinter + std::unique_ptr<TargetMachine> TM; + std::unique_ptr<AsmPrinter> Asm; + /// @} + + /// The output file we stream the linked Dwarf to. + raw_pwrite_stream &OutFile; + DWARFLinker::OutputFileType OutFileType = DWARFLinker::OutputFileType::Object; + std::function<StringRef(StringRef Input)> Translator; + + uint64_t RangesSectionSize = 0; + uint64_t RngListsSectionSize = 0; + uint64_t LocSectionSize = 0; + uint64_t LocListsSectionSize = 0; + uint64_t LineSectionSize = 0; + uint64_t FrameSectionSize = 0; + uint64_t DebugInfoSectionSize = 0; + uint64_t MacInfoSectionSize = 0; + uint64_t MacroSectionSize = 0; + + /// Keep track of emitted CUs and their Unique ID. + struct EmittedUnit { + unsigned ID; + MCSymbol *LabelBegin; + }; + std::vector<EmittedUnit> EmittedUnitsTy; + + /// Emit the pubnames or pubtypes section contribution for \p + /// Unit into \p Sec. The data is provided in \p Names. + void emitPubSectionForUnit(MCSection *Sec, StringRef Name, + const CompileUnit &Unit, + const std::vector<CompileUnit::AccelInfo> &Names); + + DWARFLinker::MessageHandlerTy WarningHandler = nullptr; +}; + +} // end namespace dwarflinker_parallel +} // end namespace llvm + +#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp index a54d2e3cc281..f082fd603610 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp @@ -6,8 +6,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "DWARFLinkerImpl.h" -namespace llvm { -namespace dwarflinker_parallel {} // end of namespace dwarflinker_parallel -} // namespace llvm +std::unique_ptr<llvm::dwarflinker_parallel::DWARFLinker> +llvm::dwarflinker_parallel::DWARFLinker::createLinker( + MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, + TranslatorFuncTy StringsTranslator) { + return std::make_unique<DWARFLinkerImpl>(ErrorHandler, WarningHandler, + StringsTranslator); +} diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h new file mode 100644 index 000000000000..1617a848512d --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h @@ -0,0 +1,156 @@ +//===- DWARFLinkerCompileUnit.h ---------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H +#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H + +#include "DWARFLinkerUnit.h" +#include "llvm/DWARFLinkerParallel/DWARFFile.h" +#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include <optional> + +namespace llvm { +namespace dwarflinker_parallel { + +struct LinkContext; +class DWARFFile; + +/// Stores all information related to a compile unit, be it in its original +/// instance of the object file or its brand new cloned and generated DIE tree. +class CompileUnit : public DwarfUnit { +public: + CompileUnit(LinkContext &, unsigned ID, StringRef ClangModuleName, + DWARFFile &File, + DWARFLinker::SwiftInterfacesMapTy *, + UnitMessageHandlerTy WarningHandler) + : DwarfUnit(ID, ClangModuleName, WarningHandler), ContaingFile(File) { + FormParams.Version = 4; + FormParams.Format = dwarf::DWARF32; + FormParams.AddrSize = 4; + UnitName = ContaingFile.FileName; + } + + CompileUnit(LinkContext &, DWARFUnit &OrigUnit, unsigned ID, + StringRef ClangModuleName, DWARFFile &File, + UnitMessageHandlerTy WarningHandler) + : DwarfUnit(ID, ClangModuleName, WarningHandler), + ContaingFile(File), OrigUnit(&OrigUnit) { + DWARFDie CUDie = OrigUnit.getUnitDIE(); + if (!CUDie) + return; + + if (File.Dwarf) + Endianess = File.Dwarf->isLittleEndian() ? support::endianness::little + : support::endianness::big; + + FormParams.Version = OrigUnit.getVersion(); + FormParams.Format = dwarf::DWARF32; + FormParams.AddrSize = OrigUnit.getAddressByteSize(); + + Language = dwarf::toUnsigned(CUDie.find(dwarf::DW_AT_language), 0); + + UnitName = ContaingFile.FileName; + SysRoot = dwarf::toStringRef(CUDie.find(dwarf::DW_AT_LLVM_sysroot)).str(); + } + + /// \defgroup Helper methods to access OrigUnit. + /// + /// @{ + + /// Returns paired compile unit from input DWARF. + DWARFUnit &getOrigUnit() const { + assert(OrigUnit != nullptr); + return *OrigUnit; + } + + const DWARFDebugInfoEntry * + getFirstChildEntry(const DWARFDebugInfoEntry *Die) const { + assert(OrigUnit != nullptr); + return OrigUnit->getFirstChildEntry(Die); + } + + const DWARFDebugInfoEntry * + getSiblingEntry(const DWARFDebugInfoEntry *Die) const { + assert(OrigUnit != nullptr); + return OrigUnit->getSiblingEntry(Die); + } + + DWARFDie getParent(const DWARFDebugInfoEntry *Die) { + assert(OrigUnit != nullptr); + return OrigUnit->getParent(Die); + } + + DWARFDie getDIEAtIndex(unsigned Index) { + assert(OrigUnit != nullptr); + return OrigUnit->getDIEAtIndex(Index); + } + + const DWARFDebugInfoEntry *getDebugInfoEntry(unsigned Index) const { + assert(OrigUnit != nullptr); + return OrigUnit->getDebugInfoEntry(Index); + } + + DWARFDie getUnitDIE(bool ExtractUnitDIEOnly = true) { + assert(OrigUnit != nullptr); + return OrigUnit->getUnitDIE(ExtractUnitDIEOnly); + } + + DWARFDie getDIE(const DWARFDebugInfoEntry *Die) { + assert(OrigUnit != nullptr); + return DWARFDie(OrigUnit, Die); + } + + uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const { + assert(OrigUnit != nullptr); + return OrigUnit->getDIEIndex(Die); + } + + uint32_t getDIEIndex(const DWARFDie &Die) const { + assert(OrigUnit != nullptr); + return OrigUnit->getDIEIndex(Die); + } + + std::optional<DWARFFormValue> find(uint32_t DieIdx, + ArrayRef<dwarf::Attribute> Attrs) const { + assert(OrigUnit != nullptr); + return find(OrigUnit->getDebugInfoEntry(DieIdx), Attrs); + } + + std::optional<DWARFFormValue> find(const DWARFDebugInfoEntry *Die, + ArrayRef<dwarf::Attribute> Attrs) const { + if (!Die) + return std::nullopt; + auto AbbrevDecl = Die->getAbbreviationDeclarationPtr(); + if (AbbrevDecl) { + for (auto Attr : Attrs) { + if (auto Value = AbbrevDecl->getAttributeValue(Die->getOffset(), Attr, + *OrigUnit)) + return Value; + } + } + return std::nullopt; + } + + std::optional<uint32_t> getDIEIndexForOffset(uint64_t Offset) { + return OrigUnit->getDIEIndexForOffset(Offset); + } + + /// @} + +private: + /// DWARFFile containing this compile unit. + DWARFFile &ContaingFile; + + /// Pointer to the paired compile unit from the input DWARF. + DWARFUnit *OrigUnit = nullptr; +}; + +} // end of namespace dwarflinker_parallel +} // end namespace llvm + +#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp new file mode 100644 index 000000000000..dfd77af92f27 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp @@ -0,0 +1,46 @@ +//=== DWARFLinkerImpl.cpp -------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "DWARFLinkerImpl.h" + +namespace llvm { +namespace dwarflinker_parallel { + +/// Similar to DWARFUnitSection::getUnitForOffset(), but returning our +/// CompileUnit object instead. +CompileUnit * +DWARFLinkerImpl::LinkContext::getUnitForOffset(CompileUnit &CurrentCU, + uint64_t Offset) const { + if (CurrentCU.isClangModule()) + return &CurrentCU; + + auto CU = llvm::upper_bound( + CompileUnits, Offset, + [](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) { + return LHS < RHS->getOrigUnit().getNextUnitOffset(); + }); + + return CU != CompileUnits.end() ? CU->get() : nullptr; +} + +Error DWARFLinkerImpl::createEmitter(const Triple &TheTriple, + OutputFileType FileType, + raw_pwrite_stream &OutFile) { + + TheDwarfEmitter = std::make_unique<DwarfEmitterImpl>( + FileType, OutFile, OutputStrings.getTranslator(), WarningHandler); + + return TheDwarfEmitter->init(TheTriple, "__DWARF"); +} + +ExtraDwarfEmitter *DWARFLinkerImpl::getEmitter() { + return TheDwarfEmitter.get(); +} + +} // end of namespace dwarflinker_parallel +} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h new file mode 100644 index 000000000000..a8fa9b4b46d8 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h @@ -0,0 +1,319 @@ +//===- DWARFLinkerImpl.h ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H +#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H + +#include "DWARFEmitterImpl.h" +#include "DWARFLinkerCompileUnit.h" +#include "llvm/ADT/AddressRanges.h" +#include "llvm/CodeGen/AccelTable.h" +#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinkerParallel/StringTable.h" + +namespace llvm { +namespace dwarflinker_parallel { + +using Offset2UnitMapTy = DenseMap<uint64_t, CompileUnit *>; + +struct RangeAttrPatch; +struct LocAttrPatch; + +class DWARFLinkerImpl : public DWARFLinker { +public: + DWARFLinkerImpl(MessageHandlerTy ErrorHandler, + MessageHandlerTy WarningHandler, + TranslatorFuncTy StringsTranslator) + : UniqueUnitID(0), ErrorHandler(ErrorHandler), + WarningHandler(WarningHandler), + OutputStrings(Strings, StringsTranslator) {} + + Error createEmitter(const Triple &TheTriple, OutputFileType FileType, + raw_pwrite_stream &OutFile) override; + + ExtraDwarfEmitter *getEmitter() override; + + /// Add object file to be linked. Pre-load compile unit die. Call + /// \p OnCUDieLoaded for each compile unit die. If specified \p File + /// has reference to the Clang module then such module would be + /// pre-loaded by \p Loader for !Update case. + /// + /// \pre NoODR, Update options should be set before call to addObjectFile. + void addObjectFile( + DWARFFile &File, ObjFileLoaderTy Loader = nullptr, + CompileUnitHandlerTy OnCUDieLoaded = [](const DWARFUnit &) {}) override {} + + /// Link debug info for added files. + Error link() override { + reportWarning("LLVM parallel dwarflinker is not implemented yet.", ""); + return Error::success(); + } + + /// \defgroup Methods setting various linking options: + /// + /// @{ + /// + + /// Allows to generate log of linking process to the standard output. + void setVerbosity(bool Verbose) override { Options.Verbose = Verbose; } + + /// Print statistics to standard output. + void setStatistics(bool Statistics) override { + Options.Statistics = Statistics; + } + + /// Verify the input DWARF. + void setVerifyInputDWARF(bool Verify) override { + Options.VerifyInputDWARF = Verify; + } + + /// Do not unique types according to ODR. + void setNoODR(bool NoODR) override { Options.NoODR = NoODR; } + + /// Update index tables only(do not modify rest of DWARF). + void setUpdateIndexTablesOnly(bool UpdateIndexTablesOnly) override { + Options.UpdateIndexTablesOnly = UpdateIndexTablesOnly; + } + + /// Allow generating valid, but non-deterministic output. + void + setAllowNonDeterministicOutput(bool AllowNonDeterministicOutput) override { + Options.AllowNonDeterministicOutput = AllowNonDeterministicOutput; + } + + /// Set to keep the enclosing function for a static variable. + void setKeepFunctionForStatic(bool KeepFunctionForStatic) override { + Options.KeepFunctionForStatic = KeepFunctionForStatic; + } + + /// Use specified number of threads for parallel files linking. + void setNumThreads(unsigned NumThreads) override { + Options.Threads = NumThreads; + } + + /// Add kind of accelerator tables to be generated. + void addAccelTableKind(AccelTableKind Kind) override { + assert(!llvm::is_contained(Options.AccelTables, Kind)); + Options.AccelTables.emplace_back(Kind); + } + + /// Set prepend path for clang modules. + void setPrependPath(const std::string &Ppath) override { + Options.PrependPath = Ppath; + } + + /// Set estimated objects files amount, for preliminary data allocation. + void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override { + ObjectContexts.reserve(ObjFilesNum); + } + + /// Set verification handler which would be used to report verification + /// errors. + void + setInputVerificationHandler(InputVerificationHandlerTy Handler) override { + Options.InputVerificationHandler = Handler; + } + + /// Set map for Swift interfaces. + void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) override { + Options.ParseableSwiftInterfaces = Map; + } + + /// Set prefix map for objects. + void setObjectPrefixMap(ObjectPrefixMapTy *Map) override { + Options.ObjectPrefixMap = Map; + } + + /// Set target DWARF version. + Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) override { + if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5)) + return createStringError(std::errc::invalid_argument, + "unsupported DWARF version: %d", + TargetDWARFVersion); + + Options.TargetDWARFVersion = TargetDWARFVersion; + return Error::success(); + } + /// @} + +protected: + /// Reports Warning. + void reportWarning(const Twine &Warning, const DWARFFile &File, + const DWARFDie *DIE = nullptr) const { + if (WarningHandler != nullptr) + WarningHandler(Warning, File.FileName, DIE); + } + + /// Reports Warning. + void reportWarning(const Twine &Warning, StringRef FileName, + const DWARFDie *DIE = nullptr) const { + if (WarningHandler != nullptr) + WarningHandler(Warning, FileName, DIE); + } + + /// Reports Error. + void reportError(const Twine &Warning, StringRef FileName, + const DWARFDie *DIE = nullptr) const { + if (ErrorHandler != nullptr) + ErrorHandler(Warning, FileName, DIE); + } + + /// Returns next available unique Compile Unit ID. + unsigned getNextUniqueUnitID() { return UniqueUnitID.fetch_add(1); } + + /// Keeps track of data associated with one object during linking. + /// i.e. source file descriptor, compilation units, output data + /// for compilation units common tables. + struct LinkContext : public OutputSections { + using UnitListTy = SmallVector<std::unique_ptr<CompileUnit>>; + + /// Keep information for referenced clang module: already loaded DWARF info + /// of the clang module and a CompileUnit of the module. + struct RefModuleUnit { + RefModuleUnit(DWARFFile &File, std::unique_ptr<CompileUnit> Unit) + : File(File), Unit(std::move(Unit)) {} + RefModuleUnit(RefModuleUnit &&Other) + : File(Other.File), Unit(std::move(Other.Unit)) {} + RefModuleUnit(const RefModuleUnit &) = delete; + + DWARFFile &File; + std::unique_ptr<CompileUnit> Unit; + }; + using ModuleUnitListTy = SmallVector<RefModuleUnit>; + + /// Object file descriptor. + DWARFFile &File; + + /// Set of Compilation Units(may be accessed asynchroniously for reading). + UnitListTy CompileUnits; + + /// Set of Compile Units for modules. + ModuleUnitListTy ModulesCompileUnits; + + /// Size of Debug info before optimizing. + uint64_t OriginalDebugInfoSize = 0; + + /// Output sections, common for all compilation units. + OutTablesFileTy OutDebugInfoBytes; + + /// Endianness for the final file. + support::endianness Endianess = support::endianness::little; + + LinkContext(DWARFFile &File) : File(File) { + if (File.Dwarf) { + if (!File.Dwarf->compile_units().empty()) + CompileUnits.reserve(File.Dwarf->getNumCompileUnits()); + + Endianess = File.Dwarf->isLittleEndian() ? support::endianness::little + : support::endianness::big; + } + } + + /// Add Compile Unit corresponding to the module. + void addModulesCompileUnit(RefModuleUnit &&Unit) { + ModulesCompileUnits.emplace_back(std::move(Unit)); + } + + /// Return Endiannes of the source DWARF information. + support::endianness getEndianness() { return Endianess; } + + /// \returns pointer to compilation unit which corresponds \p Offset. + CompileUnit *getUnitForOffset(CompileUnit &CU, uint64_t Offset) const; + }; + + /// linking options + struct DWARFLinkerOptions { + /// DWARF version for the output. + uint16_t TargetDWARFVersion = 0; + + /// Generate processing log to the standard output. + bool Verbose = false; + + /// Print statistics. + bool Statistics = false; + + /// Verify the input DWARF. + bool VerifyInputDWARF = false; + + /// Do not unique types according to ODR + bool NoODR = false; + + /// Update index tables. + bool UpdateIndexTablesOnly = false; + + /// Whether we want a static variable to force us to keep its enclosing + /// function. + bool KeepFunctionForStatic = false; + + /// Allow to generate valid, but non deterministic output. + bool AllowNonDeterministicOutput = false; + + /// Number of threads. + unsigned Threads = 1; + + /// The accelerator table kinds + SmallVector<AccelTableKind, 1> AccelTables; + + /// Prepend path for the clang modules. + std::string PrependPath; + + /// input verification handler(it might be called asynchronously). + InputVerificationHandlerTy InputVerificationHandler = nullptr; + + /// A list of all .swiftinterface files referenced by the debug + /// info, mapping Module name to path on disk. The entries need to + /// be uniqued and sorted and there are only few entries expected + /// per compile unit, which is why this is a std::map. + /// this is dsymutil specific fag. + /// + /// (it might be called asynchronously). + SwiftInterfacesMapTy *ParseableSwiftInterfaces = nullptr; + + /// A list of remappings to apply to file paths. + /// + /// (it might be called asynchronously). + ObjectPrefixMapTy *ObjectPrefixMap = nullptr; + } Options; + + /// \defgroup Data members accessed asinchroniously. + /// + /// @{ + + /// Unique ID for compile unit. + std::atomic<unsigned> UniqueUnitID; + + /// Strings pool. Keeps all strings. + StringPool Strings; + + /// error handler(it might be called asynchronously). + MessageHandlerTy ErrorHandler = nullptr; + + /// warning handler(it might be called asynchronously). + MessageHandlerTy WarningHandler = nullptr; + /// @} + + /// \defgroup Data members accessed sequentially. + /// + /// @{ + + /// Set of strings which should be emitted. + StringTable OutputStrings; + + /// Keeps all linking contexts. + SmallVector<std::unique_ptr<LinkContext>> ObjectContexts; + + /// The emitter of final dwarf file. + std::unique_ptr<DwarfEmitterImpl> TheDwarfEmitter; + /// @} +}; + +} // end namespace dwarflinker_parallel +} // end namespace llvm + +#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h new file mode 100644 index 000000000000..78e8d82ea061 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h @@ -0,0 +1,186 @@ +//===- DWARFLinkerUnit.h ----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H +#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H + +#include "OutputSections.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/CodeGen/DIE.h" +#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/Support/LEB128.h" + +namespace llvm { +namespace dwarflinker_parallel { + +using UnitMessageHandlerTy = function_ref<void( + const Twine &Error, StringRef Context, const DWARFDie *DIE)>; + +/// Each unit keeps output data as a file with debug tables +/// corresponding to the concrete unit. +using OutTablesFileTy = SmallString<0>; + +/// Base class for all Dwarf units(Compile unit/Type table unit). +class DwarfUnit : public OutputSections { +public: + virtual ~DwarfUnit() {} + DwarfUnit(unsigned ID, StringRef ClangModuleName, + UnitMessageHandlerTy WarningHandler) + : ID(ID), ClangModuleName(ClangModuleName), + WarningHandler(WarningHandler) { + FormParams.Version = 4; + FormParams.Format = dwarf::DWARF32; + FormParams.AddrSize = 4; + } + + /// Endiannes for the compile unit. + support::endianness getEndianness() const { return Endianess; } + + /// Return DWARF version. + uint16_t getVersion() const { return FormParams.Version; } + + /// Return size of header of debug_info table. + uint16_t getHeaderSize() const { return FormParams.Version >= 5 ? 12 : 11; } + + /// Return size of address. + uint8_t getAddressByteSize() const { return FormParams.AddrSize; } + + /// Return size of reference. + uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); } + + /// Return format of the Dwarf(DWARF32 or DWARF64). + /// TODO: DWARF64 is not currently supported. + dwarf::DwarfFormat getDwarfFormat() const { return FormParams.Format; } + + /// Unique id of the unit. + unsigned getUniqueID() const { return ID; } + + /// Return language of this unit. + uint16_t getLanguage() const { return Language; } + + /// Set size of this(newly generated) compile unit. + void setUnitSize(uint64_t UnitSize) { this->UnitSize = UnitSize; } + + /// Returns size of this(newly generated) compile unit. + uint64_t getUnitSize() const { return UnitSize; } + + /// Returns this unit name. + StringRef getUnitName() const { return UnitName; } + + /// Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef. + StringRef getSysRoot() { return SysRoot; } + + /// Create a Die for this unit. + void setOutputDIE(DIE *UnitDie) { NewUnit = UnitDie; } + + /// Return Die for this compile unit. + DIE *getOutputUnitDIE() const { return NewUnit; } + + /// Return true if this compile unit is from Clang module. + bool isClangModule() const { return !ClangModuleName.empty(); } + + /// Return Clang module name; + const std::string &getClangModuleName() const { return ClangModuleName; } + + /// Returns generated file keeping debug tables for this compile unit. + OutTablesFileTy &getOutDwarfBits() { return OutDebugInfoBits; } + + /// Erases generated file keeping debug tables for this compile unit. + void eraseDwarfBits() { OutDebugInfoBits = OutTablesFileTy(); } + + MCSymbol *getLabelBegin() { return LabelBegin; } + void setLabelBegin(MCSymbol *S) { LabelBegin = S; } + + /// Error reporting methods. + /// @{ + + void reportWarning(const Twine &Warning, + const DWARFDie *Die = nullptr) const { + if (WarningHandler) + WarningHandler(Warning, getUnitName(), Die); + } + void reportWarning(Error Warning) const { + handleAllErrors(std::move(Warning), [&](ErrorInfoBase &Info) { + if (WarningHandler) + WarningHandler(Info.message(), getUnitName(), nullptr); + }); + } + /// @} + + /// This structure keeps fields which would be used for creating accelerator + /// table. + struct AccelInfo { + AccelInfo(StringEntry *Name, const DIE *Die, bool SkipPubSection = false); + AccelInfo(StringEntry *Name, const DIE *Die, uint32_t QualifiedNameHash, + bool ObjCClassIsImplementation); + + /// Name of the entry. + StringEntry *Name = nullptr; + + /// Tag of the DIE this entry describes. + dwarf::Tag Tag = dwarf::DW_TAG_null; + + /// Output offset of the DIE this entry describes. + uint64_t OutOffset = 0; + + /// Hash of the fully qualified name. + uint32_t QualifiedNameHash = 0; + + /// Emit this entry only in the apple_* sections. + bool SkipPubSection = false; + + /// Is this an ObjC class implementation? + bool ObjcClassImplementation = false; + + /// Cloned Die containing acceleration info. + const DIE *Die = nullptr; + }; + +protected: + /// Unique ID for the unit. + unsigned ID = 0; + + /// Properties of the unit. + dwarf::FormParams FormParams; + + /// DIE for newly generated compile unit. + DIE *NewUnit = nullptr; + + /// The DW_AT_language of this unit. + uint16_t Language = 0; + + /// The name of this unit. + std::string UnitName; + + /// The DW_AT_LLVM_sysroot of this unit. + std::string SysRoot; + + /// If this is a Clang module, this holds the module's name. + std::string ClangModuleName; + + uint64_t UnitSize = 0; + + /// Elf file containg generated debug tables for this compile unit. + OutTablesFileTy OutDebugInfoBits; + + /// Endiannes for this compile unit. + support::endianness Endianess = support::endianness::little; + + MCSymbol *LabelBegin = nullptr; + + /// true if current unit references_to/is_referenced by other unit. + std::atomic<bool> IsInterconnectedCU = {false}; + + UnitMessageHandlerTy WarningHandler; +}; + +} // end of namespace dwarflinker_parallel +} // end namespace llvm + +#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.cpp b/llvm/lib/DWARFLinkerParallel/OutputSections.cpp new file mode 100644 index 000000000000..69c5bfaa7bdf --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/OutputSections.cpp @@ -0,0 +1,36 @@ +//=== OutputSections.cpp --------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "OutputSections.h" +#include "llvm/ADT/StringSwitch.h" + +namespace llvm { +namespace dwarflinker_parallel { + +std::optional<OutputSections::DebugSectionKind> +OutputSections::parseDebugSectionName(llvm::StringRef SecName) { + return llvm::StringSwitch<std::optional<OutputSections::DebugSectionKind>>( + SecName) + .Case("debug_info", DebugSectionKind::DebugInfo) + .Case("debug_line", DebugSectionKind::DebugLine) + .Case("debug_frame", DebugSectionKind::DebugFrame) + .Case("debug_ranges", DebugSectionKind::DebugRange) + .Case("debug_rnglists", DebugSectionKind::DebugRngLists) + .Case("debug_loc", DebugSectionKind::DebugLoc) + .Case("debug_loclists", DebugSectionKind::DebugLocLists) + .Case("debug_aranges", DebugSectionKind::DebugARanges) + .Case("debug_abbrev", DebugSectionKind::DebugAbbrev) + .Case("debug_macinfo", DebugSectionKind::DebugMacinfo) + .Case("debug_macro", DebugSectionKind::DebugMacro) + .Default(std::nullopt); + + return std::nullopt; +} + +} // end of namespace dwarflinker_parallel +} // end of namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.h b/llvm/lib/DWARFLinkerParallel/OutputSections.h new file mode 100644 index 000000000000..15ab4cc1167a --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/OutputSections.h @@ -0,0 +1,67 @@ +//===- OutputSections.h -----------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H +#define LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H + +#include "llvm/ADT/StringRef.h" +#include <array> +#include <cstdint> + +namespace llvm { +namespace dwarflinker_parallel { + +/// This class keeps offsets to the debug sections. Any object which is +/// supposed to be emitted into the debug section should use this class to +/// track debug sections offsets. +class OutputSections { +public: + /// List of tracked debug sections. + enum class DebugSectionKind : uint8_t { + DebugInfo = 0, + DebugLine, + DebugFrame, + DebugRange, + DebugRngLists, + DebugLoc, + DebugLocLists, + DebugARanges, + DebugAbbrev, + DebugMacinfo, + DebugMacro, + }; + constexpr static size_t SectionKindsNum = 11; + + /// Recognise the section name and match it with the DebugSectionKind. + static std::optional<DebugSectionKind> parseDebugSectionName(StringRef Name); + + /// When objects(f.e. compile units) are glued into the single file, + /// the debug sections corresponding to the concrete object are assigned + /// with offsets inside the whole file. This method returns offset + /// to the \p SectionKind debug section, corresponding to this object. + uint64_t getStartOffset(DebugSectionKind SectionKind) const { + return Offsets[static_cast< + typename std::underlying_type<DebugSectionKind>::type>(SectionKind)]; + } + + /// Set offset to the start of specified \p SectionKind debug section, + /// corresponding to this object. + void setStartOffset(DebugSectionKind SectionKind, uint64_t Offset) { + Offsets[static_cast<typename std::underlying_type<DebugSectionKind>::type>( + SectionKind)] = Offset; + } + +protected: + /// Offsets to the debug sections composing this object. + std::array<uint64_t, SectionKindsNum> Offsets = {0}; +}; + +} // end of namespace dwarflinker_parallel +} // end namespace llvm + +#endif // LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H diff --git a/llvm/lib/DWARFLinkerParallel/StringPool.cpp b/llvm/lib/DWARFLinkerParallel/StringPool.cpp new file mode 100644 index 000000000000..fbff6b05e3a5 --- /dev/null +++ b/llvm/lib/DWARFLinkerParallel/StringPool.cpp @@ -0,0 +1,9 @@ +//=== StringPool.cpp ------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/DWARFLinkerParallel/StringPool.h" |
