-
Notifications
You must be signed in to change notification settings - Fork 14.1k
[DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. #74725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rallel to have a common library. This creates DWARFLinkerBase library which shares code between DWARFLinker and DWARFLinkerParallel. Now AddressesMap, DWARFFile, IndexedValuesMap are shared between DWARFLinker implementations.
@llvm/pr-subscribers-debuginfo Author: None (avl-llvm) ChangesThis creates DWARFLinkerBase library which shares code between DWARFLinker and DWARFLinkerParallel. Now AddressesMap, DWARFFile, IndexedValuesMap are shared between DWARFLinker implementations. Patch is 224.10 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74725.diff 61 Files Affected:
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 b451fee4e0b723..b9d4223456cb4b 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 <cstdint>
namespace llvm {
-namespace dwarflinker_parallel {
+namespace dwarflinker {
/// 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
+} // end namespace dwarflinker
} // 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/Apple/DWARFLinker.h
similarity index 61%
rename from llvm/include/llvm/DWARFLinker/DWARFLinker.h
rename to llvm/include/llvm/DWARFLinker/Apple/DWARFLinker.h
index 2bd85e30d3b13b..0788ac7547b207 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/Apple/DWARFLinker.h
@@ -6,14 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_DWARFLINKER_DWARFLINKER_H
-#define LLVM_DWARFLINKER_DWARFLINKER_H
+#ifndef LLVM_DWARFLINKER_APPLE_DWARFLINKER_H
+#define LLVM_DWARFLINKER_APPLE_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/Apple/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,301 +26,15 @@ namespace llvm {
class DWARFExpression;
class DWARFUnit;
class DataExtractor;
-class DeclContextTree;
template <typename T> 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<int64_t>
- 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<int64_t>
- getSubprogramRelocAdjustment(const DWARFDie &DIE) = 0;
-
- /// Returns the file name associated to the AddessesMap
- virtual std::optional<StringRef> 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<char> 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 dwarflinker {
+class DeclContextTree;
using Offset2UnitMap = DenseMap<uint64_t, CompileUnit *>;
-struct DebugDieValuePool {
- DenseMap<uint64_t, uint64_t> DieValueMap;
- SmallVector<uint64_t> DieValues;
-
- uint64_t getValueIndex(uint64_t Value) {
- DenseMap<uint64_t, uint64_t>::iterator It = DieValueMap.find(Value);
- if (It == DieValueMap.end()) {
- It = DieValueMap.insert(std::make_pair(Value, DieValues.size())).first;
- DieValues.push_back(Value);
- }
- return It->second;
- }
-
- void clear() {
- DieValueMap.clear();
- DieValues.clear();
- }
-};
-
-/// DwarfEmitter presents interface to generate all debug info tables.
-class DwarfEmitter {
-public:
- virtual ~DwarfEmitter();
-
- /// Emit section named SecName with data SecData.
- virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0;
-
- /// Emit the abbreviation table \p Abbrevs to the .debug_abbrev section.
- virtual void
- emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
- unsigned DwarfVersion) = 0;
-
- /// Emit the string table described by \p Pool into .debug_str table.
- virtual void emitStrings(const NonRelocatableStringpool &Pool) = 0;
-
- /// Emit the debug string offset table described by \p StringOffsets into the
- /// .debug_str_offsets table.
- virtual void emitStringOffsets(const SmallVector<uint64_t> &StringOffsets,
- uint16_t TargetDWARFVersion) = 0;
-
- /// Emit the string table described by \p Pool into .debug_line_str table.
- virtual void emitLineStrings(const NonRelocatableStringpool &Pool) = 0;
-
- /// Emit DWARF debug names.
- virtual void emitDebugNames(DWARF5AccelTable &Table) = 0;
-
- /// Emit Apple namespaces accelerator table.
- virtual void
- emitAppleNamespaces(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0;
-
- /// Emit Apple names accelerator table.
- virtual void
- emitAppleNames(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0;
-
- /// Emit Apple Objective-C accelerator table.
- virtual void
- emitAppleObjc(AccelTable<AppleAccelTableStaticOffsetData> &Table) = 0;
-
- /// Emit Apple type accelerator table.
- virtual void
- emitAppleTypes(AccelTable<AppleAccelTableStaticTypeData> &Table) = 0;
-
- /// Emit debug ranges (.debug_ranges, .debug_rnglists) header.
- virtual MCSymbol *emitDwarfDebugRangeListHeader(const CompileUnit &Unit) = 0;
-
- /// Emit debug ranges (.debug_ranges, .debug_rnglists) fragment.
- virtual void emitDwarfDebugRangeListFragment(
- const CompileUnit &Unit, const AddressRanges &LinkedRanges,
- PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;
-
- /// Emit debug ranges (.debug_ranges, .debug_rnglists) footer.
- virtual void emitDwarfDebugRangeListFooter(const CompileUnit &Unit,
- MCSymbol *EndLabel) = 0;
-
- /// Emit debug locations (.debug_loc, .debug_loclists) header.
- virtual MCSymbol *emitDwarfDebugLocListHeader(const CompileUnit &Unit) = 0;
-
- /// Emit debug locations (.debug_loc, .debug_loclists) fragment.
- virtual void emitDwarfDebugLocListFragment(
- const CompileUnit &Unit,
- const DWARFLocationExpressionsVector &LinkedLocationExpression,
- PatchLocation Patch, DebugDieValuePool &AddrPool) = 0;
-
- /// Emit debug locations (.debug_loc, .debug_loclists) footer.
- virtual void emitDwarfDebugLocListFooter(const CompileUnit &Unit,
- MCSymbol *EndLabel) = 0;
-
- /// Emit .debug_addr header.
- virtual MCSymbol *emitDwarfDebugAddrsHeader(const CompileUnit &Unit) = 0;
-
- /// Emit the addresses described by \p Addrs into the .debug_addr section.
- virtual void emitDwarfDebugAddrs(const SmallVector<uint64_t> &Addrs,
- uint8_t AddrSize) = 0;
-
- /// Emit .debug_addr footer.
- virtual void emitDwarfDebugAddrsFooter(const CompileUnit &Unit,
- MCSymbol *EndLabel) = 0;
-
- /// Emit .debug_aranges entries for \p Unit
- virtual void
- emitDwarfDebugArangesTable(const CompileUnit &Unit,
- const AddressRanges &LinkedRanges) = 0;
-
- /// Emit specified \p LineTable into .debug_line table.
- virtual void emitLineTableForUnit(const DWARFDebugLine::LineTable &LineTable,
- const CompileUnit &Unit,
- OffsetsStringPool &DebugStrPool,
- OffsetsStringPool &DebugLineStrPool) = 0;
-
- /// Emit the .debug_pubnames contribution for \p Unit.
- virtual void emitPubNamesForUnit(const CompileUnit &Unit) = 0;
-
- /// Emit the .debug_pubtypes contribution for \p Unit.
- virtual void emitPubTypesForUnit(const CompileUnit &Unit) = 0;
-
- /// Emit a CIE.
- virtual void emitCIE(StringRef CIEBytes) = 0;
-
- /// Emit an FDE with data \p Bytes.
- virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address,
- StringRef Bytes) = 0;
-
- /// Emit the compilation unit header for \p Unit in the
- /// .debug_info section.
- ///
- /// As a side effect, this also switches the current Dwarf version
- /// of the MC layer to the one of U.getOrigUnit().
- virtual void emitCompileUnitHeader(CompileUnit &Unit,
- unsigned DwarfVersion) = 0;
-
- /// Recursively emit the DIE tree rooted at \p Die.
- virtual void emitDIE(DIE &Die) = 0;
-
- /// Emit all available macro tables(DWARFv4 and DWARFv5).
- /// Use \p UnitMacroMap to get compilation unit by macro table offset.
- /// Side effects: Fill \p StringPool with macro strings, update
- /// DW_AT_macro_info, DW_AT_macros attributes for corresponding compile
- /// units.
- virtual void emitMacroTables(DWARFContext *Context,
- const Offset2UnitMap &UnitMacroMap,
- OffsetsStringPool &StringPool) = 0;
-
- /// Returns size of generated .debug_line section.
- virtual uint64_t getLineSectionSize() const = 0;
-
- /// Returns size of generated .debug_frame section.
- virtual uint64_t getFrameSectionSize() const = 0;
-
- /// Returns size of generated .debug_ranges section.
- virtual uint64_t getRangesSectionSize() const = 0;
-
- /// Returns size of generated .debug_rnglists section.
- virtual uint64_t getRngListsSectionSize() const = 0;
-
- /// Returns size of generated .debug_info section.
- virtual uint64_t getDebugInfoSectionSize() const = 0;
-
- /// Returns size of generated .debug_macinfo section.
- virtual uint64_t getDebugMacInfoSectionSize() const = 0;
-
- /// Returns size of generated .debug_macro section.
- virtual uint64_t getDebugMacroSectionSize() const = 0;
-
- /// Returns size of generated .debug_loclists section.
- virtual uint64_t getLocListsSectionSize() const = 0;
-
- /// Returns size of generated .debug_addr section.
- virtual uint64_t getDebugAddrSectionSize() const = 0;
-
- /// Dump the file to the disk.
- virtual void finish() = 0;
-
- /// Emit the swift_ast section stored in \p Buffer.
- virtual void emitSwiftAST(StringRef Buffer) = 0;
-
- /// Emit the swift reflection section stored in \p Buffer.
- virtual void emitSwiftReflectionSection(
- llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind,
- StringRef Buffer, uint32_t Alignment, uint32_t Size) = 0;
-
- /// Returns underlying AsmPrinter.
- virtual AsmPrinter &getAsmPrinter() const = 0;
-};
-
class DwarfStreamer;
using UnitListTy = std::vector<std::unique_ptr<CompileUnit>>;
-/// This class represents DWARF information for source file
-/// and its address map.
-class DWARFFile {
-public:
- using UnloadCallbackTy = std::function<void(StringRef FileName)>;
- DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
- std::unique_ptr<AddressesMap> 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<DWARFContext> Dwarf;
-
- /// Helpful address information(list of valid address ranges, relocations).
- std::unique_ptr<AddressesMap> 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<std::string, std::string> swiftInterfacesMap;
-typedef std::map<std::string, std::string> objectPrefixMap;
-
-typedef function_ref<void(const DWARFUnit &Unit)> CompileUnitHandler;
-
/// The core of the Dwarf linking logic.
///
/// The generation of the dwarf information from the object files will be
@@ -334,46 +49,20 @@ typedef function_ref<void(const DWARFUnit &Unit)> 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<void(const Twine &Warning, StringRef Context,
- const DWARFDie *DIE)>
- messageHandler;
- DWARFLinker(messageHandler ErrorHandler, messageHandler WarningHandler,
+ DWARFLinker(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler,
std::function<StringRef(StringRef)> StringsTranslator)
- : DwarfLinkerClientID(DwarfLinkerClient::Dsymutil),
- StringsTranslator(StringsTranslator), ErrorHandler(ErrorHandler),
+ : StringsTranslator(StringsTranslator), ErrorHandler(ErrorHandler),
WarningHandler(WarningHandler) {}
static std::unique_ptr<DWARFLinker> createLinker(
- messageHandler ErrorHandler, messageHandler WarningHandler,
+ MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler,
std::function<StringRef(StringRef)> StringsTranslator = nullptr) {
return std::make_unique<DWARFLinker>(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<void(const DWARFFile &File, llvm::StringRef Output)> inputVerificationHandler;
- typedef std::function<ErrorOr<DWARFFile &>(StringRef ContainerName,
- StringRef Path)>
- objFileLoader;
-
- Error createEmitter(const Triple &TheTriple, OutputFileType FileType,
- raw_pwrite_stream &OutFile);
-
- DwarfEmitter *getEmitter();
-
/// 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
@@ -381,73 +70,84 @@ 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(const std::string &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 interfac...
[truncated]
|
High level questions:
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
This is NFC.
I did not check performance as changed things do not look like they can noticeably affect performance. But I will check and show results. |
I measured performance impact of this patch and it does not introduce any noticeable change. Anyway, I replaced String switch with an integral switch as integral switch should be faster. |
friendly ping. |
I think the challenge here is that this change looks like it's just moving files around, but in reality there are behavior differences mixed in the middle. To give you an example, when I look at the diff there are a bunch of APIs change that are pretty difficult to look at and say "this is trivially the same as before": For example:
Became
Another example:
Became:
Without having to do a lot of back-and-forth between the 1300 lines added and 1500 lines deleted, I'm not sure how to review this type of change. My suggestion would be to try a more piece-wise approach, otherwise you will probably get a "LGTM" that in reality is more like "I couldn't really check this but let's merge it". |
Ok, I will split it to smaller changes. |
…uesMap. This patch is extracted from llvm#74725. Both dwarflinkers contain similar classes for indexed values. Move the code into the DWARFLinkerBase.
This patch is extracted from llvm#74725. Put some usefull routines into the common Utils.h.
This patch is extracted from llvm#74725. The DwarfStreamer interface looks overcomplicated and has unnecessary dependencies: 1. it contains emitSwiftAST, emitSwiftReflectionSection methods which are not used by DWARFLinker. 2. its interface uses DWARFLinker classes(CompileUnit) which makes it dependend on DWARFLinker. 3. it has "AsmPrinter &getAsmPrinter()" method which provides very low level interface. This patch avoids creation of DwarfStreamer by DWARFLinker and simplifies interface: 1. dwarf_linker::classic. Now client of DWARFLinker creates DwarfStreamer and pass it to the DWARFLinker through DwarfEmitter interface. It simplifies dependence. Later it would be good to remove class DwarfStreamer from dwarf_linker::classic completely. 2. dwarf_linker::parallel. Now client of DWARFLinker sets handler of output debug sections to the DWARFLinker. It simplifies dependence to following small interface: using SectionHandlerTy = std::function<void(std::shared_ptr<SectionDescriptorBase> Section)>; virtual void setOutputDWARFHandler(const Triple &TargetTriple, SectionHandlerTy SectionHandler) = 0;
This patch is extracted from llvm#74725. The DwarfStreamer interface looks overcomplicated and has unnecessary dependencies: 1. it contains emitSwiftAST, emitSwiftReflectionSection methods which are not used by DWARFLinker. 2. its interface uses DWARFLinker classes(CompileUnit) which makes it dependend on DWARFLinker. 3. it has "AsmPrinter &getAsmPrinter()" method which provides very low level interface. This patch avoids creation of DwarfStreamer by DWARFLinker and simplifies interface: 1. dwarf_linker::classic. Now client of DWARFLinker creates DwarfStreamer and pass it to the DWARFLinker through DwarfEmitter interface. It simplifies dependence. Later it would be good to remove class DwarfStreamer from dwarf_linker::classic completely. 2. dwarf_linker::parallel. Now client of DWARFLinker sets handler of output debug sections to the DWARFLinker. It simplifies dependence to following small interface: using SectionHandlerTy = std::function<void(std::shared_ptr<SectionDescriptorBase> Section)>; virtual void setOutputDWARFHandler(const Triple &TargetTriple, SectionHandlerTy SectionHandler) = 0;
…uesMap. (llvm#77437) This patch is extracted from llvm#74725. Both dwarflinkers contain similar classes for indexed values. Move the code into the DWARFLinkerBase.
…lvm#77604) This patch is extracted from llvm#74725. Put some usefull routines into the common Utils.h.
…lvm#77604) This patch is extracted from llvm#74725. Put some usefull routines into the common Utils.h. (cherry picked from commit a02c0d9)
…uesMap. (llvm#77437) This patch is extracted from llvm#74725. Both dwarflinkers contain similar classes for indexed values. Move the code into the DWARFLinkerBase. (cherry picked from commit cf799b3)
…lvm#77932) This patch is extracted from llvm#74725. The DwarfStreamer interface looks overcomplicated and has unnecessary dependencies. This patch avoids creation of DwarfStreamer by DWARFLinker and simplifies interface. (cherry picked from commit 9ff4be6)
This creates DWARFLinkerBase library which shares code between DWARFLinker and DWARFLinkerParallel. Now AddressesMap, DWARFFile, IndexedValuesMap are shared between DWARFLinker implementations.