diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt index b0e2b7f46bef4..fb21c13c654b3 100644 --- a/bolt/lib/Rewrite/CMakeLists.txt +++ b/bolt/lib/Rewrite/CMakeLists.txt @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS MC Object Support + DWARFLinkerBase DWARFLinker AsmPrinter TargetParser diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index 05fb3e8fafe2f..8e20306925fea 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -21,7 +21,7 @@ #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/DIE.h" -#include "llvm/DWARFLinker/DWARFStreamer.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h" @@ -178,6 +178,9 @@ translateInputToOutputLocationList(const BinaryFunction &BF, return MergedLL; } +using namespace dwarf_linker; +using namespace dwarf_linker::classic; + namespace llvm { namespace bolt { /// Emits debug information into .debug_info or .debug_types section. @@ -278,10 +281,10 @@ class DIEStreamer : public DwarfStreamer { public: DIEStreamer(DIEBuilder *DIEBldr, DWARFRewriter &Rewriter, - DWARFLinker::OutputFileType OutFileType, + DWARFLinkerBase::OutputFileType OutFileType, raw_pwrite_stream &OutFile, std::function Translator, - DWARFLinker::messageHandler Warning) + DWARFLinkerBase::MessageHandlerTy Warning) : DwarfStreamer(OutFileType, OutFile, Translator, Warning), DIEBldr(DIEBldr), Rewriter(Rewriter){}; @@ -457,7 +460,7 @@ createDIEStreamer(const Triple &TheTriple, raw_pwrite_stream &OutFile, DWARFRewriter &Rewriter) { std::unique_ptr Streamer = std::make_unique( - &DIEBldr, Rewriter, llvm::DWARFLinker::OutputFileType::Object, OutFile, + &DIEBldr, Rewriter, DWARFLinkerBase::OutputFileType::Object, OutFile, [](StringRef Input) -> StringRef { return Input; }, [&](const Twine &Warning, StringRef Context, const DWARFDie *) {}); Error Err = Streamer->init(TheTriple, Swift5ReflectionSegmentName); diff --git a/llvm/include/llvm/DWARFLinkerParallel/AddressesMap.h b/llvm/include/llvm/DWARFLinker/AddressesMap.h similarity index 97% rename from llvm/include/llvm/DWARFLinkerParallel/AddressesMap.h rename to llvm/include/llvm/DWARFLinker/AddressesMap.h index b451fee4e0b72..d8b3b44074719 100644 --- a/llvm/include/llvm/DWARFLinkerParallel/AddressesMap.h +++ b/llvm/include/llvm/DWARFLinker/AddressesMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H -#define LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H +#ifndef LLVM_DWARFLINKER_ADDRESSESMAP_H +#define LLVM_DWARFLINKER_ADDRESSESMAP_H #include "llvm/ADT/AddressRanges.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" @@ -17,7 +17,7 @@ #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { /// Mapped value in the address map is the offset to apply to the /// linked address. @@ -186,7 +186,7 @@ class AddressesMap { } }; -} // end of namespace dwarflinker_parallel +} // namespace dwarf_linker } // end namespace llvm -#endif // LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H +#endif // LLVM_DWARFLINKER_ADDRESSESMAP_H diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h similarity index 81% rename from llvm/include/llvm/DWARFLinker/DWARFLinker.h rename to llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h index 2bd85e30d3b13..d3aaa3baadc47 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h @@ -6,14 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKER_DWARFLINKER_H -#define LLVM_DWARFLINKER_DWARFLINKER_H +#ifndef LLVM_DWARFLINKER_CLASSIC_DWARFLINKER_H +#define LLVM_DWARFLINKER_CLASSIC_DWARFLINKER_H #include "llvm/ADT/AddressRanges.h" #include "llvm/ADT/DenseMap.h" #include "llvm/CodeGen/AccelTable.h" #include "llvm/CodeGen/NonRelocatableStringpool.h" -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h" +#include "llvm/DWARFLinker/DWARFLinkerBase.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" @@ -25,73 +26,11 @@ namespace llvm { class DWARFExpression; class DWARFUnit; class DataExtractor; -class DeclContextTree; template class SmallVectorImpl; -enum class DwarfLinkerClient { Dsymutil, LLD, General }; - -/// AddressesMap represents information about valid addresses used -/// by debug information. Valid addresses are those which points to -/// live code sections. i.e. relocations for these addresses point -/// into sections which would be/are placed into resulting binary. -class AddressesMap { -public: - virtual ~AddressesMap(); - - /// Checks that there are valid relocations against a .debug_info - /// section. - virtual bool hasValidRelocs() = 0; - - /// Checks that the specified DWARF expression operand \p Op references live - /// code section and returns the relocation adjustment value (to get the - /// linked address this value might be added to the source expression operand - /// address). - /// \returns relocation adjustment value or std::nullopt if there is no - /// corresponding live address. - virtual std::optional - getExprOpAddressRelocAdjustment(DWARFUnit &U, - const DWARFExpression::Operation &Op, - uint64_t StartOffset, uint64_t EndOffset) = 0; - - /// Checks that the specified subprogram \p DIE references the live code - /// section and returns the relocation adjustment value (to get the linked - /// address this value might be added to the source subprogram address). - /// Allowed kinds of input DIE: DW_TAG_subprogram, DW_TAG_label. - /// \returns relocation adjustment value or std::nullopt if there is no - /// corresponding live address. - virtual std::optional - getSubprogramRelocAdjustment(const DWARFDie &DIE) = 0; - - /// Returns the file name associated to the AddessesMap - virtual std::optional getLibraryInstallName() = 0; - - /// Apply the valid relocations to the buffer \p Data, taking into - /// account that Data is at \p BaseOffset in the .debug_info section. - /// - /// \returns true whether any reloc has been applied. - virtual bool applyValidRelocs(MutableArrayRef Data, uint64_t BaseOffset, - bool IsLittleEndian) = 0; - - /// Check if the linker needs to gather and save relocation info. - virtual bool needToSaveValidRelocs() = 0; - - /// Update and save original relocations located in between StartOffset and - /// EndOffset. LinkedOffset is the value which should be added to the original - /// relocation offset to get new relocation offset in linked binary. - virtual void updateAndSaveValidRelocs(bool IsDWARF5, - uint64_t OriginalUnitOffset, - int64_t LinkedOffset, - uint64_t StartOffset, - uint64_t EndOffset) = 0; - - /// Update the valid relocations that used OriginalUnitOffset as the compile - /// unit offset, and update their values to reflect OutputUnitOffset. - virtual void updateRelocationsWithUnitOffset(uint64_t OriginalUnitOffset, - uint64_t OutputUnitOffset) = 0; - - /// Erases all data. - virtual void clear() = 0; -}; +namespace dwarf_linker { +namespace classic { +class DeclContextTree; using Offset2UnitMap = DenseMap; @@ -117,7 +56,7 @@ struct DebugDieValuePool { /// DwarfEmitter presents interface to generate all debug info tables. class DwarfEmitter { public: - virtual ~DwarfEmitter(); + virtual ~DwarfEmitter() = default; /// Emit section named SecName with data SecData. virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0; @@ -282,44 +221,6 @@ class DwarfEmitter { class DwarfStreamer; using UnitListTy = std::vector>; -/// This class represents DWARF information for source file -/// and its address map. -class DWARFFile { -public: - using UnloadCallbackTy = std::function; - DWARFFile(StringRef Name, std::unique_ptr Dwarf, - std::unique_ptr Addresses, - UnloadCallbackTy UnloadFunc = nullptr) - : FileName(Name), Dwarf(std::move(Dwarf)), - Addresses(std::move(Addresses)), UnloadFunc(UnloadFunc) {} - - /// The object file name. - StringRef FileName; - - /// The source DWARF information. - std::unique_ptr Dwarf; - - /// Helpful address information(list of valid address ranges, relocations). - std::unique_ptr Addresses; - - /// Callback to the module keeping object file to unload. - UnloadCallbackTy UnloadFunc; - - /// Unloads object file and corresponding AddressesMap and Dwarf Context. - void unload() { - Addresses.reset(); - Dwarf.reset(); - - if (UnloadFunc) - UnloadFunc(FileName); - } -}; - -typedef std::map swiftInterfacesMap; -typedef std::map objectPrefixMap; - -typedef function_ref CompileUnitHandler; - /// The core of the Dwarf linking logic. /// /// The generation of the dwarf information from the object files will be @@ -334,41 +235,20 @@ typedef function_ref CompileUnitHandler; /// a variable). These relocations are called ValidRelocs in the /// AddressesInfo and are gathered as a very first step when we start /// processing a object file. -class DWARFLinker { +class DWARFLinker : public DWARFLinkerBase { public: - typedef std::function - messageHandler; - DWARFLinker(messageHandler ErrorHandler, messageHandler WarningHandler, + DWARFLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, std::function StringsTranslator) - : DwarfLinkerClientID(DwarfLinkerClient::Dsymutil), - StringsTranslator(StringsTranslator), ErrorHandler(ErrorHandler), + : StringsTranslator(StringsTranslator), ErrorHandler(ErrorHandler), WarningHandler(WarningHandler) {} static std::unique_ptr createLinker( - messageHandler ErrorHandler, messageHandler WarningHandler, + MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, std::function StringsTranslator = nullptr) { return std::make_unique(ErrorHandler, WarningHandler, StringsTranslator); } - /// Type of output file. - enum class OutputFileType { - Object, - Assembly, - }; - - /// The kind of accelerator tables we should emit. - enum class AccelTableKind : uint8_t { - Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc. - Pub, ///< .debug_pubnames, .debug_pubtypes - DebugNames ///< .debug_names. - }; - typedef std::function inputVerificationHandler; - typedef std::function(StringRef ContainerName, - StringRef Path)> - objFileLoader; - Error createEmitter(const Triple &TheTriple, OutputFileType FileType, raw_pwrite_stream &OutFile); @@ -381,73 +261,82 @@ class DWARFLinker { /// /// \pre NoODR, Update options should be set before call to addObjectFile. void addObjectFile( - DWARFFile &File, objFileLoader Loader = nullptr, - CompileUnitHandler OnCUDieLoaded = [](const DWARFUnit &) {}); + DWARFFile &File, ObjFileLoaderTy Loader = nullptr, + CompileUnitHandlerTy OnCUDieLoaded = [](const DWARFUnit &) {}) override; /// Link debug info for added objFiles. Object files are linked all together. - Error link(); + Error link() override; /// A number of methods setting various linking options: /// Allows to generate log of linking process to the standard output. - void setVerbosity(bool Verbose) { Options.Verbose = Verbose; } + void setVerbosity(bool Verbose) override { Options.Verbose = Verbose; } /// Print statistics to standard output. - void setStatistics(bool Statistics) { Options.Statistics = Statistics; } + void setStatistics(bool Statistics) override { + Options.Statistics = Statistics; + } /// Verify the input DWARF. - void setVerifyInputDWARF(bool Verify) { Options.VerifyInputDWARF = Verify; } + void setVerifyInputDWARF(bool Verify) override { + Options.VerifyInputDWARF = Verify; + } /// Do not unique types according to ODR. - void setNoODR(bool NoODR) { Options.NoODR = NoODR; } + void setNoODR(bool NoODR) override { Options.NoODR = NoODR; } /// Update index tables only(do not modify rest of DWARF). - void setUpdateIndexTablesOnly(bool Update) { Options.Update = Update; } + void setUpdateIndexTablesOnly(bool Update) override { + Options.Update = Update; + } /// Allow generating valid, but non-deterministic output. - void setAllowNonDeterministicOutput(bool) { /* Nothing to do. */ + void setAllowNonDeterministicOutput(bool) override { /* Nothing to do. */ } /// Set whether to keep the enclosing function for a static variable. - void setKeepFunctionForStatic(bool KeepFunctionForStatic) { + void setKeepFunctionForStatic(bool KeepFunctionForStatic) override { Options.KeepFunctionForStatic = KeepFunctionForStatic; } /// Use specified number of threads for parallel files linking. - void setNumThreads(unsigned NumThreads) { Options.Threads = NumThreads; } + void setNumThreads(unsigned NumThreads) override { + Options.Threads = NumThreads; + } /// Add kind of accelerator tables to be generated. - void addAccelTableKind(AccelTableKind Kind) { + 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) { Options.PrependPath = Ppath; } + void setPrependPath(StringRef Ppath) override { Options.PrependPath = Ppath; } /// Set estimated objects files amount, for preliminary data allocation. - void setEstimatedObjfilesAmount(unsigned ObjFilesNum) { + void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override { ObjectContexts.reserve(ObjFilesNum); } /// Set verification handler which would be used to report verification /// errors. - void setInputVerificationHandler(inputVerificationHandler Handler) { + void + setInputVerificationHandler(InputVerificationHandlerTy Handler) override { Options.InputVerificationHandler = Handler; } /// Set map for Swift interfaces. - void setSwiftInterfacesMap(swiftInterfacesMap *Map) { + void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) override { Options.ParseableSwiftInterfaces = Map; } /// Set prefix map for objects. - void setObjectPrefixMap(objectPrefixMap *Map) { + void setObjectPrefixMap(ObjectPrefixMapTy *Map) override { Options.ObjectPrefixMap = Map; } /// Set target DWARF version. - Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) { + Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) override { if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5)) return createStringError(std::errc::invalid_argument, "unsupported DWARF version: %d", @@ -619,16 +508,17 @@ class DWARFLinker { /// pointing to the module, and a DW_AT_gnu_dwo_id with the module /// hash. bool registerModuleReference(const DWARFDie &CUDie, LinkContext &Context, - objFileLoader Loader, - CompileUnitHandler OnCUDieLoaded, + ObjFileLoaderTy Loader, + CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent = 0); /// Recursively add the debug info in this clang module .pcm /// file (and all the modules imported by it in a bottom-up fashion) /// to ModuleUnits. - Error loadClangModule(objFileLoader Loader, const DWARFDie &CUDie, + Error loadClangModule(ObjFileLoaderTy Loader, const DWARFDie &CUDie, const std::string &PCMFile, LinkContext &Context, - CompileUnitHandler OnCUDieLoaded, unsigned Indent = 0); + CompileUnitHandlerTy OnCUDieLoaded, + unsigned Indent = 0); /// Clone specified Clang module unit \p Unit. Error cloneModuleUnit(LinkContext &Context, RefModuleUnit &Unit, @@ -911,18 +801,16 @@ class DWARFLinker { /// Mapping the PCM filename to the DwoId. StringMap ClangModules; - DwarfLinkerClient DwarfLinkerClientID; - std::function StringsTranslator = nullptr; /// A unique ID that identifies each compile unit. unsigned UniqueUnitID = 0; // error handler - messageHandler ErrorHandler = nullptr; + MessageHandlerTy ErrorHandler = nullptr; // warning handler - messageHandler WarningHandler = nullptr; + MessageHandlerTy WarningHandler = nullptr; /// linking options struct DWARFLinkerOptions { @@ -958,20 +846,22 @@ class DWARFLinker { std::string PrependPath; // input verification handler - inputVerificationHandler InputVerificationHandler = nullptr; + 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. - swiftInterfacesMap *ParseableSwiftInterfaces = nullptr; + SwiftInterfacesMapTy *ParseableSwiftInterfaces = nullptr; /// A list of remappings to apply to file paths. - objectPrefixMap *ObjectPrefixMap = nullptr; + ObjectPrefixMapTy *ObjectPrefixMap = nullptr; } Options; }; -} // end namespace llvm +} // end of namespace classic +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKER_DWARFLINKER_H +#endif // LLVM_DWARFLINKER_CLASSIC_DWARFLINKER_H diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h similarity index 97% rename from llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h rename to llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h index 08ebd4bc70bc9..bfe544946fd90 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFLinkerCompileUnit.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKER_DWARFLINKERCOMPILEUNIT_H -#define LLVM_DWARFLINKER_DWARFLINKERCOMPILEUNIT_H +#ifndef LLVM_DWARFLINKER_CLASSIC_DWARFLINKERCOMPILEUNIT_H +#define LLVM_DWARFLINKER_CLASSIC_DWARFLINKERCOMPILEUNIT_H #include "llvm/ADT/AddressRanges.h" #include "llvm/ADT/DenseMap.h" @@ -16,6 +16,8 @@ #include namespace llvm { +namespace dwarf_linker { +namespace classic { class DeclContext; @@ -327,6 +329,8 @@ class CompileUnit { std::string ClangModuleName; }; -} // end namespace llvm +} // end of namespace classic +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKER_DWARFLINKERCOMPILEUNIT_H +#endif // LLVM_DWARFLINKER_CLASSIC_DWARFLINKERCOMPILEUNIT_H diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerDeclContext.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h similarity index 95% rename from llvm/include/llvm/DWARFLinker/DWARFLinkerDeclContext.h rename to llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h index fb02b0fc1b4df..b00f68c3be84e 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFLinkerDeclContext.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKER_DWARFLINKERDECLCONTEXT_H -#define LLVM_DWARFLINKER_DWARFLINKERDECLCONTEXT_H +#ifndef LLVM_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H +#define LLVM_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" @@ -21,6 +21,8 @@ #include namespace llvm { +namespace dwarf_linker { +namespace classic { class CompileUnit; struct DeclMapInfo; @@ -184,6 +186,8 @@ struct DeclMapInfo : private DenseMapInfo { } }; -} // end namespace llvm +} // end of namespace classic +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKER_DWARFLINKERDECLCONTEXT_H +#endif // LLVM_DWARFLINKER_CLASSIC_DWARFLINKERDECLCONTEXT_H diff --git a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h similarity index 95% rename from llvm/include/llvm/DWARFLinker/DWARFStreamer.h rename to llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h index 18eb7277bfa2d..f010c348f1214 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKER_DWARFSTREAMER_H -#define LLVM_DWARFLINKER_DWARFSTREAMER_H +#ifndef LLVM_DWARFLINKER_CLASSIC_DWARFSTREAMER_H +#define LLVM_DWARFLINKER_CLASSIC_DWARFSTREAMER_H +#include "DWARFLinker.h" #include "llvm/BinaryFormat/Swift.h" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/DWARFLinker/DWARFLinker.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInstrInfo.h" @@ -23,6 +23,12 @@ namespace llvm { template class AccelTable; +class MCCodeEmitter; +class DWARFDebugMacro; + +namespace dwarf_linker { +namespace classic { + /// User of DwarfStreamer should call initialization code /// for AsmPrinter: /// @@ -31,21 +37,19 @@ template class AccelTable; /// InitializeAllTargets(); /// InitializeAllAsmPrinters(); -class MCCodeEmitter; -class DWARFDebugMacro; - /// The Dwarf streaming logic. /// /// All interactions with the MC layer that is used to build the debug /// information binary representation are handled in this class. class DwarfStreamer : public DwarfEmitter { public: - DwarfStreamer(DWARFLinker::OutputFileType OutFileType, + DwarfStreamer(DWARFLinkerBase::OutputFileType OutFileType, raw_pwrite_stream &OutFile, std::function Translator, - DWARFLinker::messageHandler Warning) + DWARFLinkerBase::MessageHandlerTy Warning) : OutFile(OutFile), OutFileType(OutFileType), Translator(Translator), WarningHandler(Warning) {} + virtual ~DwarfStreamer() = default; Error init(Triple TheTriple, StringRef Swift5ReflectionSegmentName); @@ -310,9 +314,11 @@ class DwarfStreamer : public DwarfEmitter { const CompileUnit &Unit, const std::vector &Names); - DWARFLinker::messageHandler WarningHandler = nullptr; + DWARFLinkerBase::MessageHandlerTy WarningHandler = nullptr; }; -} // end namespace llvm +} // end of namespace classic +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKER_DWARFSTREAMER_H +#endif // LLVM_DWARFLINKER_CLASSIC_DWARFSTREAMER_H diff --git a/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h b/llvm/include/llvm/DWARFLinker/DWARFFile.h similarity index 79% rename from llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h rename to llvm/include/llvm/DWARFLinker/DWARFFile.h index c320530569bb0..c1d0fd87c7d71 100644 --- a/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h +++ b/llvm/include/llvm/DWARFLinker/DWARFFile.h @@ -6,18 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_DWARFFILE_H -#define LLVM_DWARFLINKERPARALLEL_DWARFFILE_H +#ifndef LLVM_DWARFLINKER_DWARFFILE_H +#define LLVM_DWARFLINKER_DWARFFILE_H +#include "AddressesMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DWARFLinkerParallel/AddressesMap.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" -#include "llvm/Support/Endian.h" #include #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { /// This class represents DWARF information for source file /// and it's address map. @@ -29,7 +28,9 @@ class DWARFFile { DWARFFile(StringRef Name, std::unique_ptr Dwarf, std::unique_ptr Addresses, - UnloadCallbackTy UnloadFunc = nullptr); + UnloadCallbackTy UnloadFunc = nullptr) + : FileName(Name), Dwarf(std::move(Dwarf)), + Addresses(std::move(Addresses)), UnloadFunc(UnloadFunc) {} /// Object file name. StringRef FileName; @@ -53,7 +54,7 @@ class DWARFFile { } }; -} // end namespace dwarflinker_parallel +} // namespace dwarf_linker } // end namespace llvm -#endif // LLVM_DWARFLINKERPARALLEL_DWARFFILE_H +#endif // LLVM_DWARFLINKER_DWARFFILE_H diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h new file mode 100644 index 0000000000000..626fb53d90f9f --- /dev/null +++ b/llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h @@ -0,0 +1,100 @@ +//===- DWARFLinkerBase.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_DWARFLINKER_DWARFLINKERBASE_H +#define LLVM_DWARFLINKER_DWARFLINKERBASE_H +#include "AddressesMap.h" +#include "DWARFFile.h" +#include "llvm/ADT/AddressRanges.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/DebugInfo/DWARF/DWARFContext.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" +#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" +#include "llvm/DebugInfo/DWARF/DWARFDie.h" +#include "llvm/DebugInfo/DWARF/DWARFExpression.h" +#include +namespace llvm { +class DWARFUnit; + +namespace dwarf_linker { + +/// The base interface for DWARFLinker implementations. +class DWARFLinkerBase { +public: + virtual ~DWARFLinkerBase() = default; + using MessageHandlerTy = std::function; + using ObjFileLoaderTy = std::function( + StringRef ContainerName, StringRef Path)>; + using InputVerificationHandlerTy = + std::function; + using ObjectPrefixMapTy = std::map; + using CompileUnitHandlerTy = function_ref; + using TranslatorFuncTy = std::function; + using SwiftInterfacesMapTy = std::map; + /// Type of output file. + enum class OutputFileType : uint8_t { + Object, + Assembly, + }; + /// The kind of accelerator tables to be emitted. + enum class AccelTableKind : uint8_t { + Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc. + Pub, ///< .debug_pubnames, .debug_pubtypes + DebugNames ///< .debug_names. + }; + /// Add an object file to be linked. Pre-load compile unit die. Call + /// \p OnCUDieLoaded for each compile unit die. If \p File has reference to + /// a Clang module and UpdateIndexTablesOnly == false then the module is be + /// pre-loaded by \p Loader. + /// + /// \pre a call to setNoODR(true) and/or setUpdateIndexTablesOnly(bool Update) + /// must be made when required. + virtual void addObjectFile( + DWARFFile &File, ObjFileLoaderTy Loader = nullptr, + CompileUnitHandlerTy OnCUDieLoaded = [](const DWARFUnit &) {}) = 0; + /// Link the debug info for all object files added through calls to + /// addObjectFile. + virtual Error link() = 0; + /// A number of methods setting various linking options: + /// Enable logging to standard output. + virtual void setVerbosity(bool Verbose) = 0; + /// Print statistics to standard output. + virtual void setStatistics(bool Statistics) = 0; + /// Verify the input DWARF. + virtual void setVerifyInputDWARF(bool Verify) = 0; + /// Do not unique types according to ODR. + virtual void setNoODR(bool NoODR) = 0; + /// Update index tables only (do not modify rest of DWARF). + virtual void setUpdateIndexTablesOnly(bool Update) = 0; + /// Allows generating non-deterministic output in exchange for more + /// parallelism. + virtual void setAllowNonDeterministicOutput(bool) = 0; + /// Set whether to keep the enclosing function for a static variable. + virtual void setKeepFunctionForStatic(bool KeepFunctionForStatic) = 0; + /// Use specified number of threads for parallel files linking. + virtual void setNumThreads(unsigned NumThreads) = 0; + /// Add kind of accelerator tables to be generated. + virtual void addAccelTableKind(AccelTableKind Kind) = 0; + /// Set prepend path for clang modules. + virtual void setPrependPath(StringRef Ppath) = 0; + /// Set estimated objects files amount, for preliminary data allocation. + virtual void setEstimatedObjfilesAmount(unsigned ObjFilesNum) = 0; + /// Set verification handler used to report verification errors. + virtual void + setInputVerificationHandler(InputVerificationHandlerTy Handler) = 0; + /// Set map for Swift interfaces. + virtual void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) = 0; + /// Set prefix map for objects. + virtual void setObjectPrefixMap(ObjectPrefixMapTy *Map) = 0; + /// Set target DWARF version. + virtual Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) = 0; +}; +} // end namespace dwarf_linker +} // end namespace llvm +#endif // LLVM_DWARFLINKER_DWARFLINKERBASE_H diff --git a/llvm/include/llvm/DWARFLinkerParallel/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h similarity index 58% rename from llvm/include/llvm/DWARFLinkerParallel/DWARFLinker.h rename to llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h index c16c94d65c2fe..c38a9906940ec 100644 --- a/llvm/include/llvm/DWARFLinkerParallel/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/Parallel/DWARFLinker.h @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_DWARFLINKER_H -#define LLVM_DWARFLINKERPARALLEL_DWARFLINKER_H +#ifndef LLVM_DWARFLINKER_PARALLEL_DWARFLINKER_H +#define LLVM_DWARFLINKER_PARALLEL_DWARFLINKER_H #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/DWARFLinkerParallel/DWARFFile.h" +#include "llvm/DWARFLinker/DWARFFile.h" +#include "llvm/DWARFLinker/DWARFLinkerBase.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/MC/MCDwarf.h" @@ -85,7 +86,8 @@ /// namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// ExtraDwarfEmitter allows adding extra data to the DWARFLinker output. /// The finish() method should be called after all extra data are emitted. @@ -111,31 +113,8 @@ class ExtraDwarfEmitter { virtual AsmPrinter &getAsmPrinter() const = 0; }; -class DWARFLinker { +class DWARFLinker : public DWARFLinkerBase { public: - /// Type of output file. - enum class OutputFileType { - Object, - Assembly, - }; - - /// The kind of accelerator tables we should emit. - enum class AccelTableKind : uint8_t { - Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc. - Pub, ///< .debug_pubnames, .debug_pubtypes - DebugNames ///< .debug_names. - }; - - using MessageHandlerTy = std::function; - using ObjFileLoaderTy = std::function( - StringRef ContainerName, StringRef Path)>; - using InputVerificationHandlerTy = std::function; - using ObjectPrefixMapTy = std::map; - using CompileUnitHandlerTy = function_ref; - using TranslatorFuncTy = std::function; - using SwiftInterfacesMapTy = std::map; - virtual ~DWARFLinker() = default; /// Creates dwarf linker instance. @@ -149,75 +128,10 @@ class DWARFLinker { /// Returns previously created dwarf emitter. May be nullptr. virtual ExtraDwarfEmitter *getEmitter() = 0; - - /// 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. - virtual void addObjectFile( - DWARFFile &File, ObjFileLoaderTy Loader = nullptr, - CompileUnitHandlerTy OnCUDieLoaded = [](const DWARFUnit &) {}) = 0; - - /// Link debug info for added files. - virtual Error link() = 0; - - /// \defgroup Methods setting various linking options: - /// - /// @{ - - /// Allows to generate log of linking process to the standard output. - virtual void setVerbosity(bool Verbose) = 0; - - /// Print statistics to standard output. - virtual void setStatistics(bool Statistics) = 0; - - /// Verify the input DWARF. - virtual void setVerifyInputDWARF(bool Verify) = 0; - - /// Do not unique types according to ODR. - virtual void setNoODR(bool NoODR) = 0; - - /// Update index tables only(do not modify rest of DWARF). - virtual void setUpdateIndexTablesOnly(bool UpdateIndexTablesOnly) = 0; - - /// Allow generating valid, but non-deterministic output. - virtual void - setAllowNonDeterministicOutput(bool AllowNonDeterministicOutput) = 0; - - /// Set to keep the enclosing function for a static variable. - virtual void setKeepFunctionForStatic(bool KeepFunctionForStatic) = 0; - - /// Use specified number of threads for parallel files linking. - virtual void setNumThreads(unsigned NumThreads) = 0; - - /// Add kind of accelerator tables to be generated. - virtual void addAccelTableKind(AccelTableKind Kind) = 0; - - /// Set prepend path for clang modules. - virtual void setPrependPath(const std::string &Ppath) = 0; - - /// Set estimated objects files amount, for preliminary data allocation. - virtual void setEstimatedObjfilesAmount(unsigned ObjFilesNum) = 0; - - /// Set verification handler which would be used to report verification - /// errors. - virtual void - setInputVerificationHandler(InputVerificationHandlerTy Handler) = 0; - - /// Set map for Swift interfaces. - virtual void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) = 0; - - /// Set prefix map for objects. - virtual void setObjectPrefixMap(ObjectPrefixMapTy *Map) = 0; - - /// Set target DWARF version. - virtual Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) = 0; - /// @} }; -} // end namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKERPARALLEL_DWARFLINKER_H +#endif // LLVM_DWARFLINKER_PARALLEL_DWARFLINKER_H diff --git a/llvm/include/llvm/DWARFLinkerParallel/StringPool.h b/llvm/include/llvm/DWARFLinker/StringPool.h similarity index 75% rename from llvm/include/llvm/DWARFLinkerParallel/StringPool.h rename to llvm/include/llvm/DWARFLinker/StringPool.h index e55909f343116..d0f4e211fac3e 100644 --- a/llvm/include/llvm/DWARFLinkerParallel/StringPool.h +++ b/llvm/include/llvm/DWARFLinker/StringPool.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_STRINGPOOL_H -#define LLVM_DWARFLINKERPARALLEL_STRINGPOOL_H +#ifndef LLVM_DWARFLINKER_STRINGPOOL_H +#define LLVM_DWARFLINKER_STRINGPOOL_H #include "llvm/ADT/ConcurrentHashtable.h" #include "llvm/CodeGen/DwarfStringPoolEntry.h" @@ -16,7 +16,7 @@ #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { /// StringEntry keeps data of the string: the length, external offset /// and a string body which is placed right after StringEntry. @@ -41,35 +41,38 @@ class StringPoolEntryInfo { /// \returns newly created object of KeyDataTy type. static inline StringEntry * - create(const StringRef &Key, parallel::PerThreadBumpPtrAllocator &Allocator) { + create(const StringRef &Key, + llvm::parallel::PerThreadBumpPtrAllocator &Allocator) { return StringEntry::create(Key, Allocator); } }; class StringPool : public ConcurrentHashTableByPtr { public: StringPool() : ConcurrentHashTableByPtr(Allocator) {} StringPool(size_t InitialSize) : ConcurrentHashTableByPtr(Allocator, InitialSize) {} - parallel::PerThreadBumpPtrAllocator &getAllocatorRef() { return Allocator; } + llvm::parallel::PerThreadBumpPtrAllocator &getAllocatorRef() { + return Allocator; + } void clear() { Allocator.Reset(); } private: - parallel::PerThreadBumpPtrAllocator Allocator; + llvm::parallel::PerThreadBumpPtrAllocator Allocator; }; -} // end of namespace dwarflinker_parallel +} // namespace dwarf_linker } // end namespace llvm -#endif // LLVM_DWARFLINKERPARALLEL_STRINGPOOL_H +#endif // LLVM_DWARFLINKER_STRINGPOOL_H diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h index 6b1b2ae6d7e04..df862f60cb2f1 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h @@ -18,11 +18,16 @@ namespace llvm { class raw_ostream; + +namespace dwarf_linker { +namespace classic { class DwarfStreamer; +} +} // namespace dwarf_linker class DWARFDebugMacro { - friend DwarfStreamer; - friend dwarflinker_parallel::CompileUnit; + friend dwarf_linker::classic::DwarfStreamer; + friend dwarf_linker::parallel::CompileUnit; /// DWARFv5 section 6.3.1 Macro Information Header. enum HeaderFlagMask { diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 7084081ce61a4..f20e71781f46b 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -43,9 +43,11 @@ class DWARFObject; class raw_ostream; struct DIDumpOptions; struct DWARFSection; -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { class CompileUnit; } +} // namespace dwarf_linker /// Base class describing the header of any kind of "unit." Some information /// is specific to certain unit types. We separate this class out so we can @@ -256,7 +258,7 @@ class DWARFUnit { std::shared_ptr DWO; protected: - friend dwarflinker_parallel::CompileUnit; + friend dwarf_linker::parallel::CompileUnit; /// Return the index of a \p Die entry inside the unit's DIE vector. /// diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt index 283baa6090eb9..ea22ff21820a9 100644 --- a/llvm/lib/CMakeLists.txt +++ b/llvm/lib/CMakeLists.txt @@ -14,7 +14,6 @@ add_subdirectory(BinaryFormat) add_subdirectory(Bitcode) add_subdirectory(Bitstream) add_subdirectory(DWARFLinker) -add_subdirectory(DWARFLinkerParallel) add_subdirectory(Extensions) add_subdirectory(Frontend) add_subdirectory(Transforms) diff --git a/llvm/lib/DWARFLinker/CMakeLists.txt b/llvm/lib/DWARFLinker/CMakeLists.txt index f720c5e844b36..73055a96d4a94 100644 --- a/llvm/lib/DWARFLinker/CMakeLists.txt +++ b/llvm/lib/DWARFLinker/CMakeLists.txt @@ -1,23 +1,18 @@ -add_llvm_component_library(LLVMDWARFLinker - DWARFLinkerCompileUnit.cpp - DWARFLinkerDeclContext.cpp - DWARFLinker.cpp - DWARFStreamer.cpp +add_llvm_component_library(LLVMDWARFLinkerBase + Utils.cpp ADDITIONAL_HEADER_DIRS ${LLVM_MAIN_INCLUDE_DIR}/llvm/DWARFLinker - DEPENDS intrinsics_gen LINK_COMPONENTS - AsmPrinter BinaryFormat CodeGen - CodeGenTypes DebugInfoDWARF - MC Object Support - TargetParser ) + +add_subdirectory(Classic) +add_subdirectory(Parallel) diff --git a/llvm/lib/DWARFLinker/Classic/CMakeLists.txt b/llvm/lib/DWARFLinker/Classic/CMakeLists.txt new file mode 100644 index 0000000000000..b173d42eb0153 --- /dev/null +++ b/llvm/lib/DWARFLinker/Classic/CMakeLists.txt @@ -0,0 +1,24 @@ +add_llvm_component_library(LLVMDWARFLinker + DWARFLinkerCompileUnit.cpp + DWARFLinkerDeclContext.cpp + DWARFLinker.cpp + DWARFStreamer.cpp + + ADDITIONAL_HEADER_DIRS + ${LLVM_MAIN_INCLUDE_DIR}/llvm/DWARFLinker + + DEPENDS + intrinsics_gen + + LINK_COMPONENTS + AsmPrinter + BinaryFormat + CodeGen + CodeGenTypes + DebugInfoDWARF + DWARFLinkerBase + MC + Object + Support + TargetParser + ) diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp similarity index 98% rename from llvm/lib/DWARFLinker/DWARFLinker.cpp rename to llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp index 10967123a562e..8d76c3bcf672e 100644 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinker/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFLinker.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/NonRelocatableStringpool.h" -#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" -#include "llvm/DWARFLinker/DWARFStreamer.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" @@ -39,6 +39,9 @@ namespace llvm { +using namespace dwarf_linker; +using namespace dwarf_linker::classic; + /// Hold the input and output of the debug info size in bytes. struct DebugInfoSize { uint64_t Input; @@ -137,10 +140,6 @@ static bool isTypeTag(uint16_t Tag) { return false; } -AddressesMap::~AddressesMap() = default; - -DwarfEmitter::~DwarfEmitter() = default; - bool DWARFLinker::DIECloner::getDIENames(const DWARFDie &Die, AttributesInfo &Info, OffsetsStringPool &StringPool, @@ -195,7 +194,7 @@ static SmallString<128> guessToolchainBaseDir(StringRef SysRoot) { /// DW_TAG_module blocks. static void analyzeImportedModule( const DWARFDie &DIE, CompileUnit &CU, - swiftInterfacesMap *ParseableSwiftInterfaces, + DWARFLinkerBase::SwiftInterfacesMapTy *ParseableSwiftInterfaces, std::function ReportWarning) { if (CU.getLanguage() != dwarf::DW_LANG_Swift) return; @@ -307,7 +306,8 @@ static void updateChildPruning(const DWARFDie &Die, CompileUnit &CU, static void analyzeContextInfo( const DWARFDie &DIE, unsigned ParentIdx, CompileUnit &CU, DeclContext *CurrentDeclContext, DeclContextTree &Contexts, - uint64_t ModulesEndOffset, swiftInterfacesMap *ParseableSwiftInterfaces, + uint64_t ModulesEndOffset, + DWARFLinkerBase::SwiftInterfacesMapTy *ParseableSwiftInterfaces, std::function ReportWarning) { // LIFO work list. std::vector Worklist; @@ -1357,9 +1357,9 @@ unsigned DWARFLinker::DIECloner::cloneAddressAttribute( // independently by the linker). // - If address relocated in an inline_subprogram that happens at the // beginning of its inlining function. - // To avoid above cases and to not apply relocation twice (in applyValidRelocs - // and here), read address attribute from InputDIE and apply Info.PCOffset - // here. + // To avoid above cases and to not apply relocation twice (in + // applyValidRelocs and here), read address attribute from InputDIE and apply + // Info.PCOffset here. std::optional AddrAttribute = InputDIE.find(AttrSpec.Attr); if (!AddrAttribute) @@ -1411,7 +1411,7 @@ unsigned DWARFLinker::DIECloner::cloneScalarAttribute( // need to remove the attribute. if (AttrSpec.Attr == dwarf::DW_AT_macro_info) { if (std::optional Offset = Val.getAsSectionOffset()) { - const DWARFDebugMacro *Macro = File.Dwarf->getDebugMacinfo(); + const llvm::DWARFDebugMacro *Macro = File.Dwarf->getDebugMacinfo(); if (Macro == nullptr || !Macro->hasEntryForOffset(*Offset)) return 0; } @@ -1419,7 +1419,7 @@ unsigned DWARFLinker::DIECloner::cloneScalarAttribute( if (AttrSpec.Attr == dwarf::DW_AT_macros) { if (std::optional Offset = Val.getAsSectionOffset()) { - const DWARFDebugMacro *Macro = File.Dwarf->getDebugMacro(); + const llvm::DWARFDebugMacro *Macro = File.Dwarf->getDebugMacro(); if (Macro == nullptr || !Macro->hasEntryForOffset(*Offset)) return 0; } @@ -2040,8 +2040,7 @@ static void patchAddrBase(DIE &Die, DIEInteger Offset) { } void DWARFLinker::DIECloner::emitDebugAddrSection( - CompileUnit &Unit, - const uint16_t DwarfVersion) const { + CompileUnit &Unit, const uint16_t DwarfVersion) const { if (LLVM_UNLIKELY(Linker.Options.Update)) return; @@ -2407,8 +2406,9 @@ static uint64_t getDwoId(const DWARFDie &CUDie) { return 0; } -static std::string remapPath(StringRef Path, - const objectPrefixMap &ObjectPrefixMap) { +static std::string +remapPath(StringRef Path, + const DWARFLinkerBase::ObjectPrefixMapTy &ObjectPrefixMap) { if (ObjectPrefixMap.empty()) return Path.str(); @@ -2419,8 +2419,9 @@ static std::string remapPath(StringRef Path, return p.str().str(); } -static std::string getPCMFile(const DWARFDie &CUDie, - objectPrefixMap *ObjectPrefixMap) { +static std::string +getPCMFile(const DWARFDie &CUDie, + const DWARFLinkerBase::ObjectPrefixMapTy *ObjectPrefixMap) { std::string PCMFile = dwarf::toString( CUDie.find({dwarf::DW_AT_dwo_name, dwarf::DW_AT_GNU_dwo_name}), ""); @@ -2477,8 +2478,8 @@ std::pair DWARFLinker::isClangModuleRef(const DWARFDie &CUDie, bool DWARFLinker::registerModuleReference(const DWARFDie &CUDie, LinkContext &Context, - objFileLoader Loader, - CompileUnitHandler OnCUDieLoaded, + ObjFileLoaderTy Loader, + CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent) { std::string PCMFile = getPCMFile(CUDie, Options.ObjectPrefixMap); std::pair IsClangModuleRef = @@ -2505,11 +2506,9 @@ bool DWARFLinker::registerModuleReference(const DWARFDie &CUDie, return true; } -Error DWARFLinker::loadClangModule(objFileLoader Loader, const DWARFDie &CUDie, - const std::string &PCMFile, - LinkContext &Context, - CompileUnitHandler OnCUDieLoaded, - unsigned Indent) { +Error DWARFLinker::loadClangModule( + ObjFileLoaderTy Loader, const DWARFDie &CUDie, const std::string &PCMFile, + LinkContext &Context, CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent) { uint64_t DwoId = getDwoId(CUDie); std::string ModuleName = dwarf::toString(CUDie.find(dwarf::DW_AT_name), ""); @@ -2673,8 +2672,8 @@ void DWARFLinker::copyInvariantDebugSection(DWARFContext &Dwarf) { Dwarf.getDWARFObj().getLoclistsSection().Data, "debug_loclists"); } -void DWARFLinker::addObjectFile(DWARFFile &File, objFileLoader Loader, - CompileUnitHandler OnCUDieLoaded) { +void DWARFLinker::addObjectFile(DWARFFile &File, ObjFileLoaderTy Loader, + CompileUnitHandlerTy OnCUDieLoaded) { ObjectContexts.emplace_back(LinkContext(File)); if (ObjectContexts.back().File.Dwarf) { @@ -2713,12 +2712,8 @@ Error DWARFLinker::link() { DeclContextTree ODRContexts; for (LinkContext &OptContext : ObjectContexts) { - if (Options.Verbose) { - if (DwarfLinkerClientID == DwarfLinkerClient::Dsymutil) - outs() << "DEBUG MAP OBJECT: " << OptContext.File.FileName << "\n"; - else - outs() << "OBJECT FILE: " << OptContext.File.FileName << "\n"; - } + if (Options.Verbose) + outs() << "DEBUG MAP OBJECT: " << OptContext.File.FileName << "\n"; if (!OptContext.File.Dwarf) continue; @@ -3039,7 +3034,6 @@ Error DWARFLinker::cloneModuleUnit(LinkContext &Context, RefModuleUnit &Unit, void DWARFLinker::verifyInput(const DWARFFile &File) { assert(File.Dwarf); - std::string Buffer; raw_string_ostream OS(Buffer); DIDumpOptions DumpOpts; diff --git a/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp similarity index 97% rename from llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp rename to llvm/lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp index 06559bc38c86c..1eb3a70a55135 100644 --- a/llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp +++ b/llvm/lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp @@ -6,15 +6,18 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/Support/FormatVariadic.h" namespace llvm { +using namespace dwarf_linker; +using namespace dwarf_linker::classic; + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void CompileUnit::DIEInfo::dump() { llvm::errs() << "{\n"; diff --git a/llvm/lib/DWARFLinker/DWARFLinkerDeclContext.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp similarity index 97% rename from llvm/lib/DWARFLinker/DWARFLinkerDeclContext.cpp rename to llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp index 015a4f9e8ac6b..c9c8dddce9c44 100644 --- a/llvm/lib/DWARFLinker/DWARFLinkerDeclContext.cpp +++ b/llvm/lib/DWARFLinker/Classic/DWARFLinkerDeclContext.cpp @@ -6,14 +6,17 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerDeclContext.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDie.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" namespace llvm { +using namespace dwarf_linker; +using namespace dwarf_linker::classic; + /// Set the last DIE/CU a context was seen in and, possibly invalidate the /// context if it is ambiguous. /// diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp similarity index 99% rename from llvm/lib/DWARFLinker/DWARFStreamer.cpp rename to llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp index 3ec082f4ea0c2..020bbb06449d3 100644 --- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp +++ b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinker/DWARFStreamer.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" #include "llvm/CodeGen/NonRelocatableStringpool.h" -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" #include "llvm/MC/MCAsmBackend.h" @@ -26,7 +26,9 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/TargetParser/Triple.h" -namespace llvm { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::classic; Error DwarfStreamer::init(Triple TheTriple, StringRef Swift5ReflectionSegmentName) { @@ -1426,5 +1428,3 @@ void DwarfStreamer::emitMacroTableImpl(const DWARFDebugMacro *MacroTable, } } } - -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.cpp b/llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.cpp similarity index 98% rename from llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.cpp rename to llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.cpp index 5ec25cfe5fd26..3af574c705616 100644 --- a/llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.cpp +++ b/llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.cpp @@ -11,8 +11,9 @@ #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" #include "llvm/Support/DJB.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; static uint32_t hashFullyQualifiedName(CompileUnit &InputCU, DWARFDie &InputDIE, int ChildRecurseDepth = 0) { @@ -290,6 +291,3 @@ void AcceleratorRecordsSaver::saveTypeRecord(StringEntry *Name, DIE *OutDIE, Info.TypeEntryBodyPtr = TypeEntry->getValue().load(); OutUnit.getAsTypeUnit()->saveAcceleratorInfo(Info); } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.h b/llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.h similarity index 88% rename from llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.h rename to llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.h index 5e7f4d0c3166f..bc3ea8669ece7 100644 --- a/llvm/lib/DWARFLinkerParallel/AcceleratorRecordsSaver.h +++ b/llvm/lib/DWARFLinker/Parallel/AcceleratorRecordsSaver.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_ACCELERATORRECORDSSAVER_H -#define LLVM_LIB_DWARFLINKERPARALLEL_ACCELERATORRECORDSSAVER_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_ACCELERATORRECORDSSAVER_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_ACCELERATORRECORDSSAVER_H #include "DIEAttributeCloner.h" #include "DWARFLinkerCompileUnit.h" @@ -15,7 +15,8 @@ #include "DWARFLinkerTypeUnit.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class helps to store information for accelerator entries. /// It prepares accelerator info for the certain DIE and store it inside @@ -64,7 +65,8 @@ class AcceleratorRecordsSaver { CompileUnit::OutputUnitVariantPtr OutUnit; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_ACCELERATORRECORDSSAVER_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_ACCELERATORRECORDSSAVER_H diff --git a/llvm/lib/DWARFLinkerParallel/ArrayList.h b/llvm/lib/DWARFLinker/Parallel/ArrayList.h similarity index 91% rename from llvm/lib/DWARFLinkerParallel/ArrayList.h rename to llvm/lib/DWARFLinker/Parallel/ArrayList.h index def83f91bc6f3..c48f828609be2 100644 --- a/llvm/lib/DWARFLinkerParallel/ArrayList.h +++ b/llvm/lib/DWARFLinker/Parallel/ArrayList.h @@ -6,14 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_ARRAYLIST_H -#define LLVM_LIB_DWARFLINKERPARALLEL_ARRAYLIST_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_ARRAYLIST_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_ARRAYLIST_H #include "llvm/Support/PerThreadBumpPtrAllocator.h" #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class is a simple list of T structures. It keeps elements as /// pre-allocated groups to save memory for each element's next pointer. @@ -21,7 +22,7 @@ namespace dwarflinker_parallel { /// Method add() can be called asynchronously. template class ArrayList { public: - ArrayList(parallel::PerThreadBumpPtrAllocator *Allocator) + ArrayList(llvm::parallel::PerThreadBumpPtrAllocator *Allocator) : Allocator(Allocator) {} /// Add specified \p Item to the list. @@ -156,10 +157,11 @@ template class ArrayList { std::atomic GroupsHead = nullptr; std::atomic LastGroup = nullptr; - parallel::PerThreadBumpPtrAllocator *Allocator = nullptr; + llvm::parallel::PerThreadBumpPtrAllocator *Allocator = nullptr; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_ARRAYLIST_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_ARRAYLIST_H diff --git a/llvm/lib/DWARFLinkerParallel/CMakeLists.txt b/llvm/lib/DWARFLinker/Parallel/CMakeLists.txt similarity index 94% rename from llvm/lib/DWARFLinkerParallel/CMakeLists.txt rename to llvm/lib/DWARFLinker/Parallel/CMakeLists.txt index b0f0b3910e586..5d38062975135 100644 --- a/llvm/lib/DWARFLinkerParallel/CMakeLists.txt +++ b/llvm/lib/DWARFLinker/Parallel/CMakeLists.txt @@ -3,14 +3,12 @@ add_llvm_component_library(LLVMDWARFLinkerParallel DependencyTracker.cpp DIEAttributeCloner.cpp DWARFEmitterImpl.cpp - DWARFFile.cpp DWARFLinker.cpp DWARFLinkerCompileUnit.cpp DWARFLinkerTypeUnit.cpp DWARFLinkerImpl.cpp DWARFLinkerUnit.cpp OutputSections.cpp - StringPool.cpp SyntheticTypeNameBuilder.cpp ADDITIONAL_HEADER_DIRS @@ -24,6 +22,7 @@ add_llvm_component_library(LLVMDWARFLinkerParallel BinaryFormat CodeGen DebugInfoDWARF + DWARFLinkerBase MC Object Support diff --git a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp b/llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.cpp similarity index 99% rename from llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp rename to llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.cpp index 81fc57f7cabbb..07ebd55e2c46f 100644 --- a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.cpp @@ -9,8 +9,9 @@ #include "DIEAttributeCloner.h" #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; void DIEAttributeCloner::clone() { // Extract and clone every attribute. @@ -650,6 +651,3 @@ unsigned DIEAttributeCloner::finalizeAbbreviations(bool HasChildrenToClone) { return AttrOutOffset; } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h b/llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.h similarity index 95% rename from llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h rename to llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.h index e18c0a15cefc6..6a6bd08570d7d 100644 --- a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h +++ b/llvm/lib/DWARFLinker/Parallel/DIEAttributeCloner.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DIEATTRIBUTECLONER_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DIEATTRIBUTECLONER_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DIEATTRIBUTECLONER_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DIEATTRIBUTECLONER_H #include "ArrayList.h" #include "DIEGenerator.h" @@ -16,7 +16,8 @@ #include "DWARFLinkerTypeUnit.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// Information gathered and exchanged between the various /// clone*Attr helpers about the attributes of a particular DIE. @@ -178,7 +179,8 @@ class DIEAttributeCloner { bool Use_DW_FORM_strp = false; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DIEATTRIBUTECLONER_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DIEATTRIBUTECLONER_H diff --git a/llvm/lib/DWARFLinkerParallel/DIEGenerator.h b/llvm/lib/DWARFLinker/Parallel/DIEGenerator.h similarity index 95% rename from llvm/lib/DWARFLinkerParallel/DIEGenerator.h rename to llvm/lib/DWARFLinker/Parallel/DIEGenerator.h index 42bf00f55ff18..2341dbaa8c769 100644 --- a/llvm/lib/DWARFLinkerParallel/DIEGenerator.h +++ b/llvm/lib/DWARFLinker/Parallel/DIEGenerator.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DIEGENERATOR_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DIEGENERATOR_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DIEGENERATOR_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DIEGENERATOR_H #include "DWARFLinkerGlobalData.h" #include "DWARFLinkerUnit.h" @@ -15,7 +15,8 @@ #include "llvm/Support/LEB128.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class is a helper to create output DIE tree. class DIEGenerator { @@ -174,7 +175,8 @@ class DIEGenerator { DIE *OutputDIE = nullptr; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DIEGENERATOR_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DIEGENERATOR_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp similarity index 98% rename from llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp rename to llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp index 355cfae3a6462..115167f0c7dc9 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// #include "DWARFEmitterImpl.h" -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" +#include "DWARFLinkerCompileUnit.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCObjectWriter.h" @@ -17,8 +17,9 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/FormattedStream.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; Error DwarfEmitterImpl::init(Triple TheTriple, StringRef Swift5ReflectionSegmentName) { @@ -276,6 +277,3 @@ void DwarfEmitterImpl::emitAppleTypes( Asm->OutStreamer->emitLabel(SectionBegin); emitAppleAccelTable(Asm.get(), Table, "types", SectionBegin); } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h similarity index 93% rename from llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h rename to llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h index d03336c1c11a3..89a33fe941915 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFEMITTERIMPL_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_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/DWARFLinker/Parallel/DWARFLinker.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInstrInfo.h" @@ -36,7 +36,8 @@ namespace llvm { template class AccelTable; class MCCodeEmitter; -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { using DebugNamesUnitsOffsets = std::vector>; using CompUnitIDToIdx = DenseMap; @@ -139,7 +140,8 @@ class DwarfEmitterImpl : public ExtraDwarfEmitter { uint64_t DebugInfoSectionSize = 0; }; -} // end namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFEMITTERIMPL_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFEMITTERIMPL_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp similarity index 65% rename from llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp rename to llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp index 269f24b1a13b9..ad8d28a643174 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp @@ -9,10 +9,14 @@ #include "DWARFLinkerImpl.h" #include "DependencyTracker.h" -std::unique_ptr -llvm::dwarflinker_parallel::DWARFLinker::createLinker( - MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler, - TranslatorFuncTy StringsTranslator) { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; + +std::unique_ptr +DWARFLinker::createLinker(MessageHandlerTy ErrorHandler, + MessageHandlerTy WarningHandler, + TranslatorFuncTy StringsTranslator) { return std::make_unique(ErrorHandler, WarningHandler, StringsTranslator); } diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp similarity index 99% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp index 3f0e756902727..ffcf9f365aeca 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp @@ -21,7 +21,8 @@ #include using namespace llvm; -using namespace llvm::dwarflinker_parallel; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; CompileUnit::CompileUnit(LinkingGlobalData &GlobalData, unsigned ID, StringRef ClangModuleName, DWARFFile &File, @@ -1870,7 +1871,7 @@ void CompileUnit::verifyDependencies() { Dependencies.get()->verifyKeepChain(); } -ArrayRef llvm::dwarflinker_parallel::getODRAttributes() { +ArrayRef dwarf_linker::parallel::getODRAttributes() { static dwarf::Attribute ODRAttributes[] = { dwarf::DW_AT_type, dwarf::DW_AT_specification, dwarf::DW_AT_abstract_origin, dwarf::DW_AT_import}; diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h similarity index 98% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h index 28fcc34d867db..abd978e7c0e4b 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h @@ -6,15 +6,16 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERCOMPILEUNIT_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERCOMPILEUNIT_H #include "DWARFLinkerUnit.h" -#include "llvm/DWARFLinkerParallel/DWARFFile.h" +#include "llvm/DWARFLinker/DWARFFile.h" #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { using OffsetToUnitTy = function_ref; @@ -730,7 +731,8 @@ class alignas(8) CompileUnit : public DwarfUnit { /// infinite recursion. ArrayRef getODRAttributes(); -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERCOMPILEUNIT_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERCOMPILEUNIT_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerGlobalData.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h similarity index 88% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerGlobalData.h rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h index 31724770093d6..b641343ac808c 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerGlobalData.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h @@ -6,19 +6,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERGLOBALDATA_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERGLOBALDATA_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H #include "TypePool.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" +#include "llvm/DWARFLinker/StringPool.h" #include "llvm/Support/PerThreadBumpPtrAllocator.h" namespace llvm { class DWARFDie; -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { using TranslatorFuncTy = std::function; using MessageHandlerTy = std::function( GlobalData, UniqueUnitID++, Language, GlobalFormat, GlobalEndianness); @@ -191,9 +192,10 @@ Error DWARFLinkerImpl::link() { // Set parallel options. if (GlobalData.getOptions().Threads == 0) - parallel::strategy = optimal_concurrency(OverallNumberOfCU); + llvm::parallel::strategy = optimal_concurrency(OverallNumberOfCU); else - parallel::strategy = hardware_concurrency(GlobalData.getOptions().Threads); + llvm::parallel::strategy = + hardware_concurrency(GlobalData.getOptions().Threads); // Link object files. if (GlobalData.getOptions().Threads == 1) { @@ -205,7 +207,7 @@ Error DWARFLinkerImpl::link() { Context->InputDWARFFile.unload(); } } else { - ThreadPool Pool(parallel::strategy); + ThreadPool Pool(llvm::parallel::strategy); for (std::unique_ptr &Context : ObjectContexts) Pool.async([&]() { // Link object file. @@ -486,108 +488,104 @@ Error DWARFLinkerImpl::LinkContext::link(TypeUnit *ArtificialTypeUnit) { return Error::success(); } - OriginalDebugInfoSize = getInputDebugInfoSize(); - - // Create CompileUnit structures to keep information about source - // DWARFUnit`s, load line tables. - for (const auto &OrigCU : InputDWARFFile.Dwarf->compile_units()) { - // Load only unit DIE at this stage. - auto CUDie = OrigCU->getUnitDIE(); - std::string PCMFile = - getPCMFile(CUDie, GlobalData.getOptions().ObjectPrefixMap); - - // The !isClangModuleRef condition effectively skips over fully resolved - // skeleton units. - if (!CUDie || GlobalData.getOptions().UpdateIndexTablesOnly || - !isClangModuleRef(CUDie, PCMFile, 0, true).first) { - CompileUnits.emplace_back(std::make_unique( - GlobalData, *OrigCU, UniqueUnitID.fetch_add(1), "", InputDWARFFile, - getUnitForOffset, OrigCU->getFormParams(), getEndianness())); - - // Preload line table, as it can't be loaded asynchronously. - CompileUnits.back()->loadLineTable(); - } - }; + OriginalDebugInfoSize = getInputDebugInfoSize(); + + // Create CompileUnit structures to keep information about source + // DWARFUnit`s, load line tables. + for (const auto &OrigCU : InputDWARFFile.Dwarf->compile_units()) { + // Load only unit DIE at this stage. + auto CUDie = OrigCU->getUnitDIE(); + std::string PCMFile = + getPCMFile(CUDie, GlobalData.getOptions().ObjectPrefixMap); + + // The !isClangModuleRef condition effectively skips over fully resolved + // skeleton units. + if (!CUDie || GlobalData.getOptions().UpdateIndexTablesOnly || + !isClangModuleRef(CUDie, PCMFile, 0, true).first) { + CompileUnits.emplace_back(std::make_unique( + GlobalData, *OrigCU, UniqueUnitID.fetch_add(1), "", InputDWARFFile, + getUnitForOffset, OrigCU->getFormParams(), getEndianness())); + + // Preload line table, as it can't be loaded asynchronously. + CompileUnits.back()->loadLineTable(); + } + }; - HasNewInterconnectedCUs = false; + HasNewInterconnectedCUs = false; - // Link self-sufficient compile units and discover inter-connected compile - // units. - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit(*CU, ArtificialTypeUnit); - }); + // Link self-sufficient compile units and discover inter-connected compile + // units. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit); + }); + + // Link all inter-connected units. + if (HasNewInterconnectedCUs) { + InterCUProcessingStarted = true; - // Link all inter-connected units. - if (HasNewInterconnectedCUs) { - InterCUProcessingStarted = true; - - if (Error Err = finiteLoop([&]() -> Expected { - HasNewInterconnectedCUs = false; - - // Load inter-connected units. - parallelForEach( - CompileUnits, [&](std::unique_ptr &CU) { - if (CU->isInterconnectedCU()) { - CU->maybeResetToLoadedStage(); - linkSingleCompileUnit(*CU, ArtificialTypeUnit, - CompileUnit::Stage::Loaded); - } - }); - - // Do liveness analysis for inter-connected units. - parallelForEach(CompileUnits, - [&](std::unique_ptr &CU) { - linkSingleCompileUnit( - *CU, ArtificialTypeUnit, + if (Error Err = finiteLoop([&]() -> Expected { + HasNewInterconnectedCUs = false; + + // Load inter-connected units. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + if (CU->isInterconnectedCU()) { + CU->maybeResetToLoadedStage(); + linkSingleCompileUnit(*CU, ArtificialTypeUnit, + CompileUnit::Stage::Loaded); + } + }); + + // Do liveness analysis for inter-connected units. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit, CompileUnit::Stage::LivenessAnalysisDone); - }); - - return HasNewInterconnectedCUs.load(); - })) - return Err; - - // Update dependencies. - if (Error Err = finiteLoop([&]() -> Expected { - HasNewGlobalDependency = false; - parallelForEach( - CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit( - *CU, ArtificialTypeUnit, - CompileUnit::Stage::UpdateDependenciesCompleteness); - }); - return HasNewGlobalDependency.load(); - })) - return Err; - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - if (CU->isInterconnectedCU() && - CU->getStage() == CompileUnit::Stage::LivenessAnalysisDone) - CU->setStage(CompileUnit::Stage::UpdateDependenciesCompleteness); - }); + }); - // Assign type names. - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit(*CU, ArtificialTypeUnit, - CompileUnit::Stage::TypeNamesAssigned); - }); + return HasNewInterconnectedCUs.load(); + })) + return Err; - // Clone inter-connected units. - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit(*CU, ArtificialTypeUnit, - CompileUnit::Stage::Cloned); - }); + // Update dependencies. + if (Error Err = finiteLoop([&]() -> Expected { + HasNewGlobalDependency = false; + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit( + *CU, ArtificialTypeUnit, + CompileUnit::Stage::UpdateDependenciesCompleteness); + }); + return HasNewGlobalDependency.load(); + })) + return Err; + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + if (CU->isInterconnectedCU() && + CU->getStage() == CompileUnit::Stage::LivenessAnalysisDone) + CU->setStage(CompileUnit::Stage::UpdateDependenciesCompleteness); + }); - // Update patches for inter-connected units. - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit(*CU, ArtificialTypeUnit, - CompileUnit::Stage::PatchesUpdated); - }); + // Assign type names. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit, + CompileUnit::Stage::TypeNamesAssigned); + }); - // Release data. - parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { - linkSingleCompileUnit(*CU, ArtificialTypeUnit, - CompileUnit::Stage::Cleaned); - }); - } + // Clone inter-connected units. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit, + CompileUnit::Stage::Cloned); + }); + + // Update patches for inter-connected units. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit, + CompileUnit::Stage::PatchesUpdated); + }); + + // Release data. + parallelForEach(CompileUnits, [&](std::unique_ptr &CU) { + linkSingleCompileUnit(*CU, ArtificialTypeUnit, + CompileUnit::Stage::Cleaned); + }); + } if (GlobalData.getOptions().UpdateIndexTablesOnly) { // Emit Invariant sections. @@ -598,7 +596,7 @@ Error DWARFLinkerImpl::LinkContext::link(TypeUnit *ArtificialTypeUnit) { // Emit .debug_frame section. Error ResultErr = Error::success(); - parallel::TaskGroup TGroup; + llvm::parallel::TaskGroup TGroup; // We use task group here as PerThreadBumpPtrAllocator should be called from // the threads created by ThreadPoolExecutor. TGroup.spawn([&]() { @@ -965,7 +963,7 @@ void DWARFLinkerImpl::printStatistic() { } void DWARFLinkerImpl::assignOffsets() { - parallel::TaskGroup TGroup; + llvm::parallel::TaskGroup TGroup; TGroup.spawn([&]() { assignOffsetsToStrings(); }); TGroup.spawn([&]() { assignOffsetsToSections(); }); } @@ -1134,7 +1132,7 @@ void DWARFLinkerImpl::patchOffsetsAndSizes() { } void DWARFLinkerImpl::emitCommonSectionsAndWriteCompileUnitsToTheOutput() { - parallel::TaskGroup TG; + llvm::parallel::TaskGroup TG; // Create section descriptors ahead if they are not exist at the moment. // SectionDescriptors container is not thread safe. Thus we should be sure @@ -1451,6 +1449,3 @@ void DWARFLinkerImpl::writeCommonSectionsToTheOutput() { OutSection.clearSectionContent(); }); } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h similarity index 96% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h index 60018eea121f2..b4331df5e323d 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H #include "DWARFEmitterImpl.h" #include "DWARFLinkerCompileUnit.h" @@ -15,11 +15,12 @@ #include "StringEntryToDwarfStringPoolEntryMap.h" #include "llvm/ADT/AddressRanges.h" #include "llvm/CodeGen/AccelTable.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" +#include "llvm/DWARFLinker/StringPool.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class links debug info. class DWARFLinkerImpl : public DWARFLinker { @@ -100,7 +101,7 @@ class DWARFLinkerImpl : public DWARFLinker { } /// Set prepend path for clang modules. - void setPrependPath(const std::string &Ppath) override { + void setPrependPath(StringRef Ppath) override { GlobalData.Options.PrependPath = Ppath; } @@ -374,7 +375,8 @@ class DWARFLinkerImpl : public DWARFLinker { /// @} }; -} // end namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERIMPL_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp similarity index 99% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.cpp rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp index 9d5c213085c29..397411895a8e3 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp @@ -12,7 +12,8 @@ #include "llvm/Support/LEB128.h" using namespace llvm; -using namespace llvm::dwarflinker_parallel; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; TypeUnit::TypeUnit(LinkingGlobalData &GlobalData, unsigned ID, std::optional Language, dwarf::FormParams Format, @@ -43,7 +44,7 @@ void TypeUnit::createDIETree(BumpPtrAllocator &Allocator) { // TaskGroup is created here as internal code has calls to // PerThreadBumpPtrAllocator which should be called from the task group task. - parallel::TaskGroup TG; + llvm::parallel::TaskGroup TG; TG.spawn([&]() { SectionDescriptor &DebugInfoSection = getOrCreateSectionDescriptor(DebugSectionKind::DebugInfo); @@ -134,7 +135,7 @@ void TypeUnit::prepareDataForTreeCreation() { // Type unit data created parallelly. So the order of data is not // deterministic. Order data here if we need deterministic output. - parallel::TaskGroup TG; + llvm::parallel::TaskGroup TG; if (!GlobalData.getOptions().AllowNonDeterministicOutput) { TG.spawn([&]() { diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.h similarity index 93% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.h rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.h index 97e620eee0c42..0944de8d1315a 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerTypeUnit.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerTypeUnit.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_DWARFLINKERTYPEUNIT_H -#define LLVM_DWARFLINKERPARALLEL_DWARFLINKERTYPEUNIT_H +#ifndef LLVM_DWARFLINKER_PARALLEL_DWARFLINKERTYPEUNIT_H +#define LLVM_DWARFLINKER_PARALLEL_DWARFLINKERTYPEUNIT_H #include "DWARFLinkerUnit.h" #include "llvm/CodeGen/DIE.h" @@ -15,7 +15,8 @@ #include "llvm/DebugInfo/DWARF/DWARFUnit.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// Type Unit is used to represent an artificial compilation unit /// which keeps all type information. This type information is referenced @@ -132,7 +133,8 @@ class TypeUnit : public DwarfUnit { std::mutex DebugStringIndexMapMutex; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_DWARFLINKERPARALLEL_DWARFLINKERTYPEUNIT_H +#endif // LLVM_DWARFLINKER_PARALLEL_DWARFLINKERTYPEUNIT_H diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.cpp similarity index 98% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.cpp index b1da1900d65ef..93def34aa4fda 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.cpp @@ -10,8 +10,9 @@ #include "DWARFEmitterImpl.h" #include "DebugLineSectionEmitter.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; void DwarfUnit::assignAbbrev(DIEAbbrev &Abbrev) { // Check the set for priors. @@ -245,6 +246,3 @@ void DwarfUnit::emitPubAccelerators() { OutSection.OS.tell() - *TypesLengthOffset); } } - -} // end of namespace dwarflinker_parallel -} // end of namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.h similarity index 94% rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.h index 9640a8ee711eb..36c24372e4942 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.h @@ -6,20 +6,21 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERUNIT_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERUNIT_H #include "DWARFLinkerGlobalData.h" #include "IndexedValuesMap.h" #include "OutputSections.h" #include "llvm/CodeGen/DIE.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" +#include "llvm/DWARFLinker/StringPool.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" #include "llvm/Support/LEB128.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { class DwarfUnit; using MacroOffset2UnitMapTy = DenseMap; @@ -215,7 +216,8 @@ inline bool isODRLanguage(uint16_t Language) { return false; } -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DWARFLINKERUNIT_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERUNIT_H diff --git a/llvm/lib/DWARFLinkerParallel/DebugLineSectionEmitter.h b/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h similarity index 97% rename from llvm/lib/DWARFLinkerParallel/DebugLineSectionEmitter.h rename to llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h index 27c63fad712f1..545d04cfbe43d 100644 --- a/llvm/lib/DWARFLinkerParallel/DebugLineSectionEmitter.h +++ b/llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h @@ -6,18 +6,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DEBUGLINESECTIONEMITTER_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DEBUGLINESECTIONEMITTER_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DEBUGLINESECTIONEMITTER_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DEBUGLINESECTIONEMITTER_H #include "DWARFEmitterImpl.h" -#include "llvm/DWARFLinkerParallel/AddressesMap.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "llvm/DWARFLinker/AddressesMap.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" #include "llvm/DebugInfo/DWARF/DWARFObject.h" #include "llvm/MC/MCTargetOptionsCommandFlags.h" #include "llvm/MC/TargetRegistry.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class emits specified line table into the .debug_line section. class DebugLineSectionEmitter { @@ -389,7 +390,8 @@ class DebugLineSectionEmitter { std::unique_ptr MSTI; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DEBUGLINESECTIONEMITTER_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DEBUGLINESECTIONEMITTER_H diff --git a/llvm/lib/DWARFLinkerParallel/DependencyTracker.cpp b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp similarity index 99% rename from llvm/lib/DWARFLinkerParallel/DependencyTracker.cpp rename to llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp index 052eb6cf57d41..04152e7f9f2b0 100644 --- a/llvm/lib/DWARFLinkerParallel/DependencyTracker.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.cpp @@ -9,8 +9,9 @@ #include "DependencyTracker.h" #include "llvm/Support/FormatVariadic.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; /// A broken link in the keep chain. By recording both the parent and the child /// we can show only broken links for DIEs with multiple children. @@ -834,6 +835,3 @@ bool DependencyTracker::isLiveSubprogramEntry(const UnitEntryPairTy &Entry) { Entry.CU->addFunctionRange(*LowPc, *HighPc, *RelocAdjustment); return true; } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DependencyTracker.h b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.h similarity index 96% rename from llvm/lib/DWARFLinkerParallel/DependencyTracker.h rename to llvm/lib/DWARFLinker/Parallel/DependencyTracker.h index b0b6ad3a1e8cf..4a0d985c8aaa6 100644 --- a/llvm/lib/DWARFLinkerParallel/DependencyTracker.h +++ b/llvm/lib/DWARFLinker/Parallel/DependencyTracker.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_DEPENDENCYTRACKER_H -#define LLVM_LIB_DWARFLINKERPARALLEL_DEPENDENCYTRACKER_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DEPENDENCYTRACKER_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_DEPENDENCYTRACKER_H #include "DWARFLinkerCompileUnit.h" #include "llvm/ADT/PointerIntPair.h" @@ -17,7 +17,8 @@ namespace llvm { class DWARFDebugInfoEntry; class DWARFDie; -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class discovers DIEs dependencies: marks "live" DIEs, marks DIE /// locations (whether DIE should be cloned as regular DIE or it should be put @@ -266,7 +267,8 @@ class DependencyTracker { RootEntriesListTy Dependencies; }; -} // end namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_DEPENDENCYTRACKER_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DEPENDENCYTRACKER_H diff --git a/llvm/lib/DWARFLinkerParallel/IndexedValuesMap.h b/llvm/lib/DWARFLinker/Parallel/IndexedValuesMap.h similarity index 78% rename from llvm/lib/DWARFLinkerParallel/IndexedValuesMap.h rename to llvm/lib/DWARFLinker/Parallel/IndexedValuesMap.h index 0dc8de860a42e..b592ce37937bc 100644 --- a/llvm/lib/DWARFLinkerParallel/IndexedValuesMap.h +++ b/llvm/lib/DWARFLinker/Parallel/IndexedValuesMap.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_INDEXEDVALUESMAP_H -#define LLVM_LIB_DWARFLINKERPARALLEL_INDEXEDVALUESMAP_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -15,7 +15,8 @@ #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { template class IndexedValuesMap { public: @@ -43,7 +44,8 @@ template class IndexedValuesMap { SmallVector Values; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_INDEXEDVALUESMAP_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.cpp b/llvm/lib/DWARFLinker/Parallel/OutputSections.cpp similarity index 95% rename from llvm/lib/DWARFLinkerParallel/OutputSections.cpp rename to llvm/lib/DWARFLinker/Parallel/OutputSections.cpp index 730ae0f83d7b2..cd1205b60f85b 100644 --- a/llvm/lib/DWARFLinkerParallel/OutputSections.cpp +++ b/llvm/lib/DWARFLinker/Parallel/OutputSections.cpp @@ -11,22 +11,12 @@ #include "DWARFLinkerTypeUnit.h" #include "llvm/ADT/StringSwitch.h" -namespace llvm { -namespace dwarflinker_parallel { - -static constexpr StringLiteral SectionNames[SectionKindsNum] = { - "debug_info", "debug_line", "debug_frame", "debug_ranges", - "debug_rnglists", "debug_loc", "debug_loclists", "debug_aranges", - "debug_abbrev", "debug_macinfo", "debug_macro", "debug_addr", - "debug_str", "debug_line_str", "debug_str_offsets", "debug_pubnames", - "debug_pubtypes", "debug_names", "apple_names", "apple_namespac", - "apple_objc", "apple_types"}; - -const StringLiteral &getSectionName(DebugSectionKind SectionKind) { - return SectionNames[static_cast(SectionKind)]; -} +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; -std::optional parseDebugTableName(llvm::StringRef SecName) { +std::optional +dwarf_linker::parallel::parseDebugTableName(llvm::StringRef SecName) { return llvm::StringSwitch>( SecName.substr(SecName.find_first_not_of("._"))) .Case(getSectionName(DebugSectionKind::DebugInfo), @@ -531,6 +521,3 @@ void OutputSections::applyPatches( Section.apply(Patch.PatchOffset, dwarf::DW_FORM_sec_offset, FinalValue); }); } - -} // end of namespace dwarflinker_parallel -} // end of namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.h b/llvm/lib/DWARFLinker/Parallel/OutputSections.h similarity index 94% rename from llvm/lib/DWARFLinkerParallel/OutputSections.h rename to llvm/lib/DWARFLinker/Parallel/OutputSections.h index 0f394b0810ea9..b9df2228920a9 100644 --- a/llvm/lib/DWARFLinkerParallel/OutputSections.h +++ b/llvm/lib/DWARFLinker/Parallel/OutputSections.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H -#define LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H #include "ArrayList.h" #include "StringEntryToDwarfStringPoolEntryMap.h" @@ -15,7 +15,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/DwarfStringPoolEntry.h" -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/StringPool.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFObject.h" #include "llvm/Object/ObjectFile.h" @@ -29,7 +29,8 @@ #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { class TypeUnit; @@ -62,12 +63,22 @@ enum class DebugSectionKind : uint8_t { constexpr static size_t SectionKindsNum = static_cast(DebugSectionKind::NumberOfEnumEntries); +static constexpr StringLiteral SectionNames[SectionKindsNum] = { + "debug_info", "debug_line", "debug_frame", "debug_ranges", + "debug_rnglists", "debug_loc", "debug_loclists", "debug_aranges", + "debug_abbrev", "debug_macinfo", "debug_macro", "debug_addr", + "debug_str", "debug_line_str", "debug_str_offsets", "debug_pubnames", + "debug_pubtypes", "debug_names", "apple_names", "apple_namespac", + "apple_objc", "apple_types"}; + +static constexpr const StringLiteral & +getSectionName(DebugSectionKind SectionKind) { + return SectionNames[static_cast(SectionKind)]; +} + /// Recognise the table name and match it with the DebugSectionKind. std::optional parseDebugTableName(StringRef Name); -/// Return the name of the section. -const StringLiteral &getSectionName(DebugSectionKind SectionKind); - /// There are fields(sizes, offsets) which should be updated after /// sections are generated. To remember offsets and related data /// the descendants of SectionPatch structure should be used. @@ -498,7 +509,8 @@ class OutputSections { SectionsSetTy SectionDescriptors; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_OUTPUTSECTIONS_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_OUTPUTSECTIONS_H diff --git a/llvm/lib/DWARFLinkerParallel/StringEntryToDwarfStringPoolEntryMap.h b/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h similarity index 84% rename from llvm/lib/DWARFLinkerParallel/StringEntryToDwarfStringPoolEntryMap.h rename to llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h index b4c74d0adba97..858f224777dba 100644 --- a/llvm/lib/DWARFLinkerParallel/StringEntryToDwarfStringPoolEntryMap.h +++ b/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h @@ -6,15 +6,16 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_DWARFLINKERPARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H -#define LLVM_LIB_DWARFLINKERPARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H #include "DWARFLinkerGlobalData.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/StringPool.h" namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { /// This class creates a DwarfStringPoolEntry for the corresponding StringEntry. class StringEntryToDwarfStringPoolEntryMap { @@ -66,7 +67,8 @@ class StringEntryToDwarfStringPoolEntryMap { LinkingGlobalData &GlobalData; }; -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H diff --git a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp similarity index 99% rename from llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp rename to llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp index a9b4478e33c40..1554946c2c047 100644 --- a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.cpp +++ b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp @@ -12,8 +12,9 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h" #include "llvm/Support/ScopedPrinter.h" -namespace llvm { -namespace dwarflinker_parallel { +using namespace llvm; +using namespace dwarf_linker; +using namespace dwarf_linker::parallel; Error SyntheticTypeNameBuilder::assignName( UnitEntryPairTy InputUnitEntryPair, @@ -762,6 +763,3 @@ OrderedChildrenIndexAssigner::getChildIndex( OrderedChildIdxs[*ArrayIndex]++; return Result; } - -} // end of namespace dwarflinker_parallel -} // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.h b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.h similarity index 94% rename from llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.h rename to llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.h index c9dce4e94fb0d..8465c0d77b9cb 100644 --- a/llvm/lib/DWARFLinkerParallel/SyntheticTypeNameBuilder.h +++ b/llvm/lib/DWARFLinker/Parallel/SyntheticTypeNameBuilder.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===/ -#ifndef LLVM_LIB_DWARFLINKERNEXT_SYNTHETICTYPENAMEBUILDER_H -#define LLVM_LIB_DWARFLINKERNEXT_SYNTHETICTYPENAMEBUILDER_H +#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_SYNTHETICTYPENAMEBUILDER_H +#define LLVM_LIB_DWARFLINKER_PARALLEL_SYNTHETICTYPENAMEBUILDER_H #include "DWARFLinkerCompileUnit.h" #include "DWARFLinkerGlobalData.h" @@ -17,7 +17,8 @@ namespace llvm { class DWARFDebugInfoEntry; -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { struct LinkContext; class TypeTableUnit; class CompileUnit; @@ -149,7 +150,8 @@ class OrderedChildrenIndexAssigner { OrderedChildrenIndexesArrayTy ChildIndexesWidth = {0}; }; -} // end namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERNEXT_SYNTHETICTYPENAMEBUILDER_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_SYNTHETICTYPENAMEBUILDER_H diff --git a/llvm/lib/DWARFLinkerParallel/TypePool.h b/llvm/lib/DWARFLinker/Parallel/TypePool.h similarity index 84% rename from llvm/lib/DWARFLinkerParallel/TypePool.h rename to llvm/lib/DWARFLinker/Parallel/TypePool.h index bbb3261027ce8..547532977262b 100644 --- a/llvm/lib/DWARFLinkerParallel/TypePool.h +++ b/llvm/lib/DWARFLinker/Parallel/TypePool.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DWARFLINKERPARALLEL_TYPEPOOL_H -#define LLVM_DWARFLINKERPARALLEL_TYPEPOOL_H +#ifndef LLVM_DWARFLINKER_PARALLEL_TYPEPOOL_H +#define LLVM_DWARFLINKER_PARALLEL_TYPEPOOL_H #include "ArrayList.h" #include "llvm/ADT/ConcurrentHashtable.h" @@ -17,7 +17,8 @@ #include namespace llvm { -namespace dwarflinker_parallel { +namespace dwarf_linker { +namespace parallel { class TypePool; class CompileUnit; @@ -41,7 +42,8 @@ class TypeEntryBody { bool hasOnlyDeclaration() const { return Die == nullptr; } /// Creates type DIE for the specified name. - static TypeEntryBody *create(parallel::PerThreadBumpPtrAllocator &Allocator) { + static TypeEntryBody * + create(llvm::parallel::PerThreadBumpPtrAllocator &Allocator) { TypeEntryBody *Result = Allocator.Allocate(); new (Result) TypeEntryBody(Allocator); return Result; @@ -72,7 +74,7 @@ class TypeEntryBody { TypeEntryBody &operator=(const TypeEntryBody &RHS) = delete; TypeEntryBody &operator=(const TypeEntryBody &&RHS) = delete; - TypeEntryBody(parallel::PerThreadBumpPtrAllocator &Allocator) + TypeEntryBody(llvm::parallel::PerThreadBumpPtrAllocator &Allocator) : Children(&Allocator) {} }; @@ -95,20 +97,22 @@ class TypeEntryInfo { /// \returns newly created object of KeyDataTy type. static inline TypeEntry * - create(const StringRef &Key, parallel::PerThreadBumpPtrAllocator &Allocator) { + create(const StringRef &Key, + llvm::parallel::PerThreadBumpPtrAllocator &Allocator) { return TypeEntry::create(Key, Allocator); } }; /// TypePool keeps type descriptors which contain partially cloned DIE /// correspinding to each type. Types are identified by names. -class TypePool : ConcurrentHashTableByPtr { +class TypePool + : ConcurrentHashTableByPtr { public: TypePool() : ConcurrentHashTableByPtr(Allocator) { Root = TypeEntry::create("", Allocator); Root->getValue().store(TypeEntryBody::create(Allocator)); @@ -116,7 +120,7 @@ class TypePool : ConcurrentHashTableByPtr::insert(Name) .first; } @@ -168,10 +172,11 @@ class TypePool : ConcurrentHashTableByPtr()> Iteration, return createStringError(std::errc::invalid_argument, "Infinite recursion"); } -} // end of namespace dwarflinker_parallel -} // end namespace llvm +} // end of namespace parallel +} // end of namespace dwarf_linker +} // end of namespace llvm -#endif // LLVM_LIB_DWARFLINKERPARALLEL_UTILS_H +#endif // LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H diff --git a/llvm/lib/DWARFLinkerParallel/StringPool.cpp b/llvm/lib/DWARFLinker/Utils.cpp similarity index 68% rename from llvm/lib/DWARFLinkerParallel/StringPool.cpp rename to llvm/lib/DWARFLinker/Utils.cpp index fbff6b05e3a54..e8b0fe303aaef 100644 --- a/llvm/lib/DWARFLinkerParallel/StringPool.cpp +++ b/llvm/lib/DWARFLinker/Utils.cpp @@ -1,9 +1,7 @@ -//=== StringPool.cpp ------------------------------------------------------===// +//===- Utils.cpp ------------------------------------------------*- 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 // //===----------------------------------------------------------------------===// - -#include "llvm/DWARFLinkerParallel/StringPool.h" diff --git a/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp b/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp deleted file mode 100644 index 5a3486e6398d4..0000000000000 --- a/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//=== DWARFFile.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/DWARFFile.h" -#include "DWARFLinkerGlobalData.h" - -llvm::dwarflinker_parallel::DWARFFile::DWARFFile( - StringRef Name, std::unique_ptr Dwarf, - std::unique_ptr Addresses, - DWARFFile::UnloadCallbackTy UnloadFunc) - : FileName(Name), Dwarf(std::move(Dwarf)), Addresses(std::move(Addresses)), - UnloadFunc(UnloadFunc) {} diff --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt index c612bfd9150c4..0e407f6fa1db4 100644 --- a/llvm/tools/dsymutil/CMakeLists.txt +++ b/llvm/tools/dsymutil/CMakeLists.txt @@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS AsmPrinter CodeGen CodeGenTypes + DWARFLinkerBase DWARFLinker DWARFLinkerParallel DebugInfoDWARF diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index 33d053c745b0c..89a15e5916e21 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -27,8 +27,9 @@ #include "llvm/CodeGen/DIE.h" #include "llvm/CodeGen/NonRelocatableStringpool.h" #include "llvm/Config/config.h" -#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" @@ -100,6 +101,8 @@ namespace llvm { static mc::RegisterMCTargetOptionsFlags MOF; +using namespace dwarf_linker; + namespace dsymutil { static void dumpDIE(const DWARFDie *DIE, bool Verbose) { @@ -185,10 +188,8 @@ static Error remarksErrorHandler(const DebugMapObject &DMO, return createFileError(FE->getFileName(), std::move(NewE)); } -template Error DwarfLinkerForBinary::emitRelocations( - const DebugMap &DM, - std::vector> &ObjectsForLinking) { + const DebugMap &DM, std::vector &ObjectsForLinking) { // Return early if the "Resources" directory is not being written to. if (!Options.ResourceDir) return Error::success(); @@ -262,13 +263,12 @@ static Error emitRemarks(const LinkOptions &Options, StringRef BinaryPath, return Error::success(); } -template -ErrorOr> DwarfLinkerForBinary::loadObject( +ErrorOr> DwarfLinkerForBinary::loadObject( const DebugMapObject &Obj, const DebugMap &DebugMap, remarks::RemarkLinker &RL, std::shared_ptr DLBRM) { auto ErrorOrObj = loadObject(Obj, DebugMap.getTriple()); - std::unique_ptr Res; + std::unique_ptr Res; if (ErrorOrObj) { auto Context = DWARFContext::create( @@ -285,9 +285,9 @@ ErrorOr> DwarfLinkerForBinary::loadObject( }); }); DLBRM->init(*Context); - Res = std::make_unique( + Res = std::make_unique( Obj.getObjectFilename(), std::move(Context), - std::make_unique(*this, *ErrorOrObj, Obj, DLBRM), + std::make_unique(*this, *ErrorOrObj, Obj, DLBRM), [&](StringRef FileName) { BinHolder.eraseObjectEntry(FileName); }); Error E = RL.link(*ErrorOrObj); @@ -309,7 +309,7 @@ static bool binaryHasStrippableSwiftReflectionSections( // need to copy them to the .dSYM. Only copy them for binaries where the // linker omitted the reflection metadata. if (!Map.getBinaryPath().empty() && - Options.FileType == DWARFLinker::OutputFileType::Object) { + Options.FileType == DWARFLinkerBase::OutputFileType::Object) { auto ObjectEntry = BinHolder.getObjectEntry(Map.getBinaryPath()); // If ObjectEntry or Object has an error, no binary exists, therefore no @@ -593,28 +593,10 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata( } bool DwarfLinkerForBinary::link(const DebugMap &Map) { - if (Options.DWARFLinkerType == DsymutilDWARFLinkerType::LLVM) { - dwarflinker_parallel::DWARFLinker::OutputFileType DWARFLinkerOutputType; - switch (Options.FileType) { - case DWARFLinker::OutputFileType::Object: - DWARFLinkerOutputType = - dwarflinker_parallel::DWARFLinker::OutputFileType::Object; - break; - - case DWARFLinker::OutputFileType::Assembly: - DWARFLinkerOutputType = - dwarflinker_parallel::DWARFLinker::OutputFileType::Assembly; - break; - } - - return linkImpl>( - Map, DWARFLinkerOutputType); - } + if (Options.DWARFLinkerType == DsymutilDWARFLinkerType::LLVM) + return linkImpl(Map, Options.FileType); - return linkImpl>( - Map, Options.FileType); + return linkImpl(Map, Options.FileType); } template @@ -645,11 +627,11 @@ void setAcceleratorTables(Linker &GeneralLinker, llvm_unreachable("All cases handled above!"); } -template +template bool DwarfLinkerForBinary::linkImpl( const DebugMap &Map, typename Linker::OutputFileType ObjectType) { - std::vector> ObjectsForLinking; + std::vector ObjectsForLinking; DebugMap DebugMap(Map.getTriple(), Map.getBinaryPath()); @@ -691,22 +673,22 @@ bool DwarfLinkerForBinary::linkImpl( GeneralLinker->setNumThreads(Options.Threads); GeneralLinker->setPrependPath(Options.PrependPath); GeneralLinker->setKeepFunctionForStatic(Options.KeepFunctionForStatic); - GeneralLinker->setInputVerificationHandler([&](const OutDwarfFile &File, llvm::StringRef Output) { - std::lock_guard Guard(ErrorHandlerMutex); - if (Options.Verbose) - errs() << Output; - warn("input verification failed", File.FileName); - HasVerificationErrors = true; - }); + GeneralLinker->setInputVerificationHandler( + [&](const DWARFFile &File, llvm::StringRef Output) { + std::lock_guard Guard(ErrorHandlerMutex); + if (Options.Verbose) + errs() << Output; + warn("input verification failed", File.FileName); + HasVerificationErrors = true; + }); auto Loader = [&](StringRef ContainerName, - StringRef Path) -> ErrorOr { + StringRef Path) -> ErrorOr { auto &Obj = DebugMap.addDebugMapObject( Path, sys::TimePoint(), MachO::N_OSO); auto DLBRelocMap = std::make_shared(); - if (ErrorOr> ErrorOrObj = - loadObject(Obj, DebugMap, RL, - DLBRelocMap)) { + if (ErrorOr> ErrorOrObj = + loadObject(Obj, DebugMap, RL, DLBRelocMap)) { ObjectsForLinking.emplace_back(std::move(*ErrorOrObj), DLBRelocMap); return *ObjectsForLinking.back().Object; } else { @@ -820,15 +802,15 @@ bool DwarfLinkerForBinary::linkImpl( } auto DLBRelocMap = std::make_shared(); - if (ErrorOr> ErrorOrObj = - loadObject(*Obj, Map, RL, DLBRelocMap)) { + if (ErrorOr> ErrorOrObj = + loadObject(*Obj, Map, RL, DLBRelocMap)) { ObjectsForLinking.emplace_back(std::move(*ErrorOrObj), DLBRelocMap); GeneralLinker->addObjectFile(*ObjectsForLinking.back().Object, Loader, OnCUDieLoaded); } else { ObjectsForLinking.push_back( - {std::make_unique(Obj->getObjectFilename(), nullptr, - nullptr), + {std::make_unique(Obj->getObjectFilename(), nullptr, + nullptr), DLBRelocMap}); GeneralLinker->addObjectFile(*ObjectsForLinking.back().Object); } @@ -855,8 +837,7 @@ bool DwarfLinkerForBinary::linkImpl( if (Options.NoOutput) return true; - if (Error E = - emitRelocations(Map, ObjectsForLinking)) + if (Error E = emitRelocations(Map, ObjectsForLinking)) return error(toString(std::move(E))); if (Options.ResourceDir && !ParseableSwiftInterfaces.empty()) { @@ -879,12 +860,9 @@ bool DwarfLinkerForBinary::linkImpl( /// Iterate over the relocations of the given \p Section and /// store the ones that correspond to debug map entries into the /// ValidRelocs array. -template -void DwarfLinkerForBinary::AddressManager:: - findValidRelocsMachO(const object::SectionRef &Section, - const object::MachOObjectFile &Obj, - const DebugMapObject &DMO, - std::vector &ValidRelocs) { +void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO( + const object::SectionRef &Section, const object::MachOObjectFile &Obj, + const DebugMapObject &DMO, std::vector &ValidRelocs) { Expected ContentsOrErr = Section.getContents(); if (!ContentsOrErr) { consumeError(ContentsOrErr.takeError()); @@ -961,8 +939,7 @@ void DwarfLinkerForBinary::AddressManager:: /// Dispatch the valid relocation finding logic to the /// appropriate handler depending on the object file format. -template -bool DwarfLinkerForBinary::AddressManager::findValidRelocs( +bool DwarfLinkerForBinary::AddressManager::findValidRelocs( const object::SectionRef &Section, const object::ObjectFile &Obj, const DebugMapObject &DMO, std::vector &Relocs) { // Dispatch to the right handler depending on the file type. @@ -987,10 +964,8 @@ bool DwarfLinkerForBinary::AddressManager::findValidRelocs( /// entries in the debug map. These relocations will drive the Dwarf link by /// indicating which DIEs refer to symbols present in the linked binary. /// \returns whether there are any valid relocations in the debug info. -template -bool DwarfLinkerForBinary::AddressManager:: - findValidRelocsInDebugSections(const object::ObjectFile &Obj, - const DebugMapObject &DMO) { +bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugSections( + const object::ObjectFile &Obj, const DebugMapObject &DMO) { // Find the debug_info section. bool FoundValidRelocs = false; for (const object::SectionRef &Section : Obj.sections()) { @@ -1011,9 +986,7 @@ bool DwarfLinkerForBinary::AddressManager:: return FoundValidRelocs; } -template -std::vector -DwarfLinkerForBinary::AddressManager::getRelocations( +std::vector DwarfLinkerForBinary::AddressManager::getRelocations( const std::vector &Relocs, uint64_t StartPos, uint64_t EndPos) { std::vector Res; @@ -1030,9 +1003,7 @@ DwarfLinkerForBinary::AddressManager::getRelocations( return Res; } -template -void DwarfLinkerForBinary::AddressManager::printReloc( - const ValidReloc &Reloc) { +void DwarfLinkerForBinary::AddressManager::printReloc(const ValidReloc &Reloc) { const auto &Mapping = Reloc.SymbolMapping; const uint64_t ObjectAddress = Mapping.ObjectAddress ? uint64_t(*Mapping.ObjectAddress) @@ -1043,18 +1014,16 @@ void DwarfLinkerForBinary::AddressManager::printReloc( uint64_t(Mapping.BinaryAddress)); } -template -int64_t DwarfLinkerForBinary::AddressManager::getRelocValue( - const ValidReloc &Reloc) { +int64_t +DwarfLinkerForBinary::AddressManager::getRelocValue(const ValidReloc &Reloc) { int64_t AddrAdjust = relocate(Reloc); if (Reloc.SymbolMapping.ObjectAddress) AddrAdjust -= uint64_t(*Reloc.SymbolMapping.ObjectAddress); return AddrAdjust; } -template std::optional -DwarfLinkerForBinary::AddressManager::hasValidRelocationAt( +DwarfLinkerForBinary::AddressManager::hasValidRelocationAt( const std::vector &AllRelocs, uint64_t StartOffset, uint64_t EndOffset) { std::vector Relocs = @@ -1089,11 +1058,10 @@ getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx, return std::make_pair(Offset, End); } -template -std::optional DwarfLinkerForBinary::AddressManager:: - getExprOpAddressRelocAdjustment(DWARFUnit &U, - const DWARFExpression::Operation &Op, - uint64_t StartOffset, uint64_t EndOffset) { +std::optional +DwarfLinkerForBinary::AddressManager::getExprOpAddressRelocAdjustment( + DWARFUnit &U, const DWARFExpression::Operation &Op, uint64_t StartOffset, + uint64_t EndOffset) { switch (Op.getCode()) { default: { assert(false && "Specified operation does not have address operand"); @@ -1116,9 +1084,9 @@ std::optional DwarfLinkerForBinary::AddressManager:: return std::nullopt; } -template -std::optional DwarfLinkerForBinary::AddressManager< - AddressesMapBase>::getSubprogramRelocAdjustment(const DWARFDie &DIE) { +std::optional +DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment( + const DWARFDie &DIE) { const auto *Abbrev = DIE.getAbbreviationDeclarationPtr(); std::optional LowPcIdx = @@ -1158,25 +1126,19 @@ std::optional DwarfLinkerForBinary::AddressManager< } } -template -std::optional DwarfLinkerForBinary::AddressManager< - AddressesMapBase>::getLibraryInstallName() { +std::optional +DwarfLinkerForBinary::AddressManager::getLibraryInstallName() { return LibInstallName; } -template -uint64_t DwarfLinkerForBinary::AddressManager::relocate( - const ValidReloc &Reloc) const { +uint64_t +DwarfLinkerForBinary::AddressManager::relocate(const ValidReloc &Reloc) const { return Reloc.SymbolMapping.BinaryAddress + Reloc.Addend; } -template -void DwarfLinkerForBinary::AddressManager< - AddressesMapBase>::updateAndSaveValidRelocs(bool IsDWARF5, - uint64_t OriginalUnitOffset, - int64_t LinkedOffset, - uint64_t StartOffset, - uint64_t EndOffset) { +void DwarfLinkerForBinary::AddressManager::updateAndSaveValidRelocs( + bool IsDWARF5, uint64_t OriginalUnitOffset, int64_t LinkedOffset, + uint64_t StartOffset, uint64_t EndOffset) { std::vector InRelocs = getRelocations(ValidDebugInfoRelocs, StartOffset, EndOffset); if (IsDWARF5) @@ -1185,10 +1147,8 @@ void DwarfLinkerForBinary::AddressManager< IsDWARF5, InRelocs, OriginalUnitOffset, LinkedOffset); } -template -void DwarfLinkerForBinary::AddressManager:: - updateRelocationsWithUnitOffset(uint64_t OriginalUnitOffset, - uint64_t OutputUnitOffset) { +void DwarfLinkerForBinary::AddressManager::updateRelocationsWithUnitOffset( + uint64_t OriginalUnitOffset, uint64_t OutputUnitOffset) { DwarfLinkerRelocMap->updateRelocationsWithUnitOffset(OriginalUnitOffset, OutputUnitOffset); } @@ -1200,8 +1160,7 @@ void DwarfLinkerForBinary::AddressManager:: /// monotonic \p BaseOffset values. /// /// \returns whether any reloc has been applied. -template -bool DwarfLinkerForBinary::AddressManager::applyValidRelocs( +bool DwarfLinkerForBinary::AddressManager::applyValidRelocs( MutableArrayRef Data, uint64_t BaseOffset, bool IsLittleEndian) { std::vector Relocs = getRelocations( diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h index 328cd9197d0d1..052c6a899fd76 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.h +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.h @@ -14,10 +14,6 @@ #include "LinkUtils.h" #include "MachOUtils.h" #include "RelocationMap.h" -#include "llvm/DWARFLinker/DWARFLinker.h" -#include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h" -#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" -#include "llvm/DWARFLinker/DWARFStreamer.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/Remarks/RemarkFormat.h" #include "llvm/Remarks/RemarkLinker.h" @@ -25,6 +21,8 @@ #include namespace llvm { +using namespace dwarf_linker; + namespace dsymutil { /// DwarfLinkerForBinaryRelocationMap contains the logic to handle the @@ -55,12 +53,12 @@ class DwarfLinkerForBinaryRelocationMap { DwarfLinkerForBinaryRelocationMap() = default; }; -template struct ObjectWithRelocMap { +struct ObjectWithRelocMap { ObjectWithRelocMap( - std::unique_ptr Object, + std::unique_ptr Object, std::shared_ptr OutRelocs) : Object(std::move(Object)), OutRelocs(OutRelocs) {} - std::unique_ptr Object; + std::unique_ptr Object; std::shared_ptr OutRelocs; }; @@ -104,8 +102,7 @@ class DwarfLinkerForBinary { private: /// Keeps track of relocations. - template - class AddressManager : public AddressesMapBase { + class AddressManager : public dwarf_linker::AddressesMap { const DwarfLinkerForBinary &Linker; @@ -241,8 +238,7 @@ class DwarfLinkerForBinary { /// Attempt to load a debug object from disk. ErrorOr loadObject(const DebugMapObject &Obj, const Triple &triple); - template - ErrorOr> + ErrorOr> loadObject(const DebugMapObject &Obj, const DebugMap &DebugMap, remarks::RemarkLinker &RL, std::shared_ptr DLBRM); @@ -264,14 +260,12 @@ class DwarfLinkerForBinary { std::vector &RelocationsToApply); - template + template bool linkImpl(const DebugMap &Map, typename Linker::OutputFileType ObjectType); - template - Error emitRelocations( - const DebugMap &DM, - std::vector> &ObjectsForLinking); + Error emitRelocations(const DebugMap &DM, + std::vector &ObjectsForLinking); raw_fd_ostream &OutFile; BinaryHolder &BinHolder; diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h index 0bf6d9aac1a3f..97785dd872f5a 100644 --- a/llvm/tools/dsymutil/LinkUtils.h +++ b/llvm/tools/dsymutil/LinkUtils.h @@ -16,8 +16,8 @@ #include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/WithColor.h" -#include "llvm/DWARFLinker/DWARFLinker.h" -#include "llvm/DWARFLinker/DWARFStreamer.h" +#include "llvm/DWARFLinker/Classic/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" #include namespace llvm { @@ -72,7 +72,8 @@ struct LinkOptions { unsigned Threads = 1; // Output file type. - DWARFLinker::OutputFileType FileType = DWARFLinker::OutputFileType::Object; + dwarf_linker::DWARFLinkerBase::OutputFileType FileType = + dwarf_linker::DWARFLinkerBase::OutputFileType::Object; /// The accelerator table kind DsymutilAccelTableKind TheAccelTableKind; diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index 2dd123318e00b..a461d9e20a212 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -55,6 +55,7 @@ using namespace llvm; using namespace llvm::dsymutil; using namespace object; +using namespace llvm::dwarf_linker; namespace { enum ID { @@ -373,7 +374,7 @@ static Expected getOptions(opt::InputArgList &Args) { Options.Toolchain = Toolchain->getValue(); if (Args.hasArg(OPT_assembly)) - Options.LinkOpts.FileType = DWARFLinker::OutputFileType::Assembly; + Options.LinkOpts.FileType = DWARFLinkerBase::OutputFileType::Assembly; if (opt::Arg *NumThreads = Args.getLastArg(OPT_threads)) Options.LinkOpts.Threads = atoi(NumThreads->getValue()); diff --git a/llvm/tools/llvm-dwarfutil/CMakeLists.txt b/llvm/tools/llvm-dwarfutil/CMakeLists.txt index b2585799b10c1..91b25207b4f72 100644 --- a/llvm/tools/llvm-dwarfutil/CMakeLists.txt +++ b/llvm/tools/llvm-dwarfutil/CMakeLists.txt @@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS AllTargetsDescs AllTargetsInfos CodeGenTypes + DWARFLinkerBase DWARFLinker DWARFLinkerParallel DebugInfoDWARF diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp index 02a94596ec764..d6504992b56eb 100644 --- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp +++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp @@ -9,9 +9,9 @@ #include "DebugInfoLinker.h" #include "Error.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/DWARFLinker/DWARFLinker.h" -#include "llvm/DWARFLinker/DWARFStreamer.h" -#include "llvm/DWARFLinkerParallel/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFLinker.h" +#include "llvm/DWARFLinker/Classic/DWARFStreamer.h" +#include "llvm/DWARFLinker/Parallel/DWARFLinker.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/Object/ObjectFile.h" @@ -19,6 +19,8 @@ #include namespace llvm { +using namespace dwarf_linker; + namespace dwarfutil { // ObjFileAddressMap allows to check whether specified DIE referencing @@ -37,8 +39,7 @@ namespace dwarfutil { // exec: [LowPC, HighPC] is not inside address ranges of .text sections // // universal: maxpc and bfd -template -class ObjFileAddressMap : public AddressMapBase { +class ObjFileAddressMap : public AddressesMap { public: ObjFileAddressMap(DWARFContext &Context, const Options &Options, object::ObjectFile &ObjFile) @@ -298,7 +299,7 @@ static std::string getMessageForDeletedAcceleratorTables( return Message; } -template +template Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, raw_pwrite_stream &OutStream) { std::mutex ErrorHandlerMutex; @@ -345,7 +346,7 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, DebugInfoLinker->setVerbosity(Options.Verbose); DebugInfoLinker->setUpdateIndexTablesOnly(!Options.DoGarbageCollection); - std::vector> ObjectsForLinking(1); + std::vector> ObjectsForLinking(1); // Add object files to the DWARFLinker. std::unique_ptr Context = DWARFContext::create( @@ -360,11 +361,10 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, ReportWarn(Info.message(), "", nullptr); }); }); - std::unique_ptr> AddressesMap( - std::make_unique>(*Context, Options, - File)); + std::unique_ptr AddressesMap( + std::make_unique(*Context, Options, File)); - ObjectsForLinking[0] = std::make_unique( + ObjectsForLinking[0] = std::make_unique( File.getFileName(), std::move(Context), std::move(AddressesMap)); uint16_t MaxDWARFVersion = 0; @@ -400,7 +400,7 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, for (typename Linker::AccelTableKind Table : AccelTables) DebugInfoLinker->addAccelTableKind(Table); - for (std::unique_ptr &CurFile : ObjectsForLinking) { + for (std::unique_ptr &CurFile : ObjectsForLinking) { SmallVector AccelTableNamesToReplace; SmallVector AccelTableNamesToDelete; @@ -452,13 +452,9 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, Error linkDebugInfo(object::ObjectFile &File, const Options &Options, raw_pwrite_stream &OutStream) { if (Options.UseLLVMDWARFLinker) - return linkDebugInfoImpl(File, Options, - OutStream); + return linkDebugInfoImpl(File, Options, OutStream); else - return linkDebugInfoImpl( - File, Options, OutStream); + return linkDebugInfoImpl(File, Options, OutStream); } } // end of namespace dwarfutil diff --git a/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp b/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp index 84199f696a59d..2612e763648b3 100644 --- a/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp +++ b/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DWARFLinkerParallel/StringPool.h" +#include "llvm/DWARFLinker/StringPool.h" #include "llvm/Support/Parallel.h" #include "gtest/gtest.h" #include using namespace llvm; -using namespace dwarflinker_parallel; +using namespace dwarf_linker; namespace {