[llvm] [DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. Part 1. (PR #75925)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 7 12:52:45 PST 2024
https://github.com/avl-llvm updated https://github.com/llvm/llvm-project/pull/75925
>From 0bcdb5c05491a5fcc454d2d256e06d4fd2d23fd9 Mon Sep 17 00:00:00 2001
From: Alexey Lapshin <a.v.lapshin at mail.ru>
Date: Mon, 18 Dec 2023 15:49:29 +0300
Subject: [PATCH] [DWARFLinker][DWARFLinkerParallel][NFC] Refactor
DWARFLinker&DWARFLinkerParallel to have a common library. Part 1.
This patch creates DWARFLinkerBase library, places DWARFLinker code into
DWARFLinker\Apple, places DWARFLinkerParallel into DWARFLinker\LLVM.
This patch is NFC.
---
bolt/lib/Rewrite/CMakeLists.txt | 1 +
bolt/lib/Rewrite/DWARFRewriter.cpp | 11 +-
.../AddressesMap.h | 10 +-
.../DWARFLinker/{ => Classic}/DWARFLinker.h | 216 +++++-------------
.../{ => Classic}/DWARFLinkerCompileUnit.h | 12 +-
.../{ => Classic}/DWARFLinkerDeclContext.h | 12 +-
.../DWARFLinker/{ => Classic}/DWARFStreamer.h | 28 ++-
.../DWARFFile.h | 17 +-
.../llvm/DWARFLinker/DWARFLinkerBase.h | 100 ++++++++
.../Parallel}/DWARFLinker.h | 108 +--------
.../StringPool.h | 25 +-
.../llvm/DebugInfo/DWARF/DWARFDebugMacro.h | 9 +-
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h | 6 +-
llvm/lib/CMakeLists.txt | 1 -
llvm/lib/DWARFLinker/CMakeLists.txt | 15 +-
llvm/lib/DWARFLinker/Classic/CMakeLists.txt | 24 ++
.../DWARFLinker/{ => Classic}/DWARFLinker.cpp | 66 +++---
.../{ => Classic}/DWARFLinkerCompileUnit.cpp | 7 +-
.../{ => Classic}/DWARFLinkerDeclContext.cpp | 7 +-
.../{ => Classic}/DWARFStreamer.cpp | 10 +-
.../Parallel}/AcceleratorRecordsSaver.cpp | 8 +-
.../Parallel}/AcceleratorRecordsSaver.h | 14 +-
.../Parallel}/ArrayList.h | 18 +-
.../Parallel}/CMakeLists.txt | 3 +-
.../Parallel}/DIEAttributeCloner.cpp | 8 +-
.../Parallel}/DIEAttributeCloner.h | 14 +-
.../Parallel}/DIEGenerator.h | 14 +-
.../Parallel}/DWARFEmitterImpl.cpp | 10 +-
.../Parallel}/DWARFEmitterImpl.h | 16 +-
.../Parallel}/DWARFLinker.cpp | 12 +-
.../Parallel}/DWARFLinkerCompileUnit.cpp | 5 +-
.../Parallel}/DWARFLinkerCompileUnit.h | 16 +-
.../Parallel}/DWARFLinkerGlobalData.h | 24 +-
.../Parallel}/DWARFLinkerImpl.cpp | 207 ++++++++---------
.../Parallel}/DWARFLinkerImpl.h | 20 +-
.../Parallel}/DWARFLinkerTypeUnit.cpp | 7 +-
.../Parallel}/DWARFLinkerTypeUnit.h | 14 +-
.../Parallel}/DWARFLinkerUnit.cpp | 8 +-
.../Parallel}/DWARFLinkerUnit.h | 18 +-
.../Parallel}/DebugLineSectionEmitter.h | 18 +-
.../Parallel}/DependencyTracker.cpp | 8 +-
.../Parallel}/DependencyTracker.h | 14 +-
.../Parallel}/IndexedValuesMap.h | 14 +-
.../Parallel}/OutputSections.cpp | 23 +-
.../Parallel}/OutputSections.h | 32 ++-
.../StringEntryToDwarfStringPoolEntryMap.h | 16 +-
.../Parallel}/SyntheticTypeNameBuilder.cpp | 8 +-
.../Parallel}/SyntheticTypeNameBuilder.h | 14 +-
.../Parallel}/TypePool.h | 35 +--
.../Parallel}/Utils.h | 14 +-
.../StringPool.cpp => DWARFLinker/Utils.cpp} | 4 +-
llvm/lib/DWARFLinkerParallel/DWARFFile.cpp | 17 --
llvm/tools/dsymutil/CMakeLists.txt | 1 +
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp | 157 ++++++-------
llvm/tools/dsymutil/DwarfLinkerForBinary.h | 26 +--
llvm/tools/dsymutil/LinkUtils.h | 7 +-
llvm/tools/dsymutil/dsymutil.cpp | 3 +-
llvm/tools/llvm-dwarfutil/CMakeLists.txt | 1 +
llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp | 32 ++-
.../DWARFLinkerParallel/StringPoolTest.cpp | 4 +-
60 files changed, 746 insertions(+), 823 deletions(-)
rename llvm/include/llvm/{DWARFLinkerParallel => DWARFLinker}/AddressesMap.h (97%)
rename llvm/include/llvm/DWARFLinker/{ => Classic}/DWARFLinker.h (81%)
rename llvm/include/llvm/DWARFLinker/{ => Classic}/DWARFLinkerCompileUnit.h (97%)
rename llvm/include/llvm/DWARFLinker/{ => Classic}/DWARFLinkerDeclContext.h (95%)
rename llvm/include/llvm/DWARFLinker/{ => Classic}/DWARFStreamer.h (95%)
rename llvm/include/llvm/{DWARFLinkerParallel => DWARFLinker}/DWARFFile.h (79%)
create mode 100644 llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
rename llvm/include/llvm/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinker.h (58%)
rename llvm/include/llvm/{DWARFLinkerParallel => DWARFLinker}/StringPool.h (75%)
create mode 100644 llvm/lib/DWARFLinker/Classic/CMakeLists.txt
rename llvm/lib/DWARFLinker/{ => Classic}/DWARFLinker.cpp (98%)
rename llvm/lib/DWARFLinker/{ => Classic}/DWARFLinkerCompileUnit.cpp (97%)
rename llvm/lib/DWARFLinker/{ => Classic}/DWARFLinkerDeclContext.cpp (97%)
rename llvm/lib/DWARFLinker/{ => Classic}/DWARFStreamer.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/AcceleratorRecordsSaver.cpp (98%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/AcceleratorRecordsSaver.h (88%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/ArrayList.h (91%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/CMakeLists.txt (94%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DIEAttributeCloner.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DIEAttributeCloner.h (95%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DIEGenerator.h (95%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFEmitterImpl.cpp (98%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFEmitterImpl.h (93%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinker.cpp (65%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerCompileUnit.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerCompileUnit.h (98%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerGlobalData.h (88%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerImpl.cpp (91%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerImpl.h (96%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerTypeUnit.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerTypeUnit.h (93%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerUnit.cpp (98%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DWARFLinkerUnit.h (94%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DebugLineSectionEmitter.h (97%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DependencyTracker.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/DependencyTracker.h (96%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/IndexedValuesMap.h (78%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/OutputSections.cpp (95%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/OutputSections.h (94%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/StringEntryToDwarfStringPoolEntryMap.h (84%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/SyntheticTypeNameBuilder.cpp (99%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/SyntheticTypeNameBuilder.h (94%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/TypePool.h (84%)
rename llvm/lib/{DWARFLinkerParallel => DWARFLinker/Parallel}/Utils.h (81%)
rename llvm/lib/{DWARFLinkerParallel/StringPool.cpp => DWARFLinker/Utils.cpp} (68%)
delete mode 100644 llvm/lib/DWARFLinkerParallel/DWARFFile.cpp
diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt
index b0e2b7f46bef4c..fb21c13c654b3e 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 05fb3e8fafe2f7..8e20306925feac 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<StringRef(StringRef Input)> 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<DIEStreamer> Streamer = std::make_unique<DIEStreamer>(
- &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 b451fee4e0b723..d8b3b440747192 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 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 2bd85e30d3b13b..d3aaa3baadc47d 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 <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 dwarf_linker {
+namespace classic {
+class DeclContextTree;
using Offset2UnitMap = DenseMap<uint64_t, CompileUnit *>;
@@ -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<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,41 +235,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);
@@ -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<uint64_t> ClangModules;
- DwarfLinkerClient DwarfLinkerClientID;
-
std::function<StringRef(StringRef)> 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 08ebd4bc70bc93..bfe544946fd903 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 <optional>
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 fb02b0fc1b4dfe..b00f68c3be84e1 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 <atomic>
namespace llvm {
+namespace dwarf_linker {
+namespace classic {
class CompileUnit;
struct DeclMapInfo;
@@ -184,6 +186,8 @@ struct DeclMapInfo : private DenseMapInfo<DeclContext *> {
}
};
-} // 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 18eb7277bfa2df..f010c348f12148 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 <typename DataT> 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 <typename DataT> 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<StringRef(StringRef Input)> 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<CompileUnit::AccelInfo> &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 c320530569bb05..c1d0fd87c7d711 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 <functional>
#include <memory>
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<DWARFContext> Dwarf,
std::unique_ptr<AddressesMap> 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 00000000000000..626fb53d90f9fa
--- /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 <map>
+namespace llvm {
+class DWARFUnit;
+
+namespace dwarf_linker {
+
+/// The base interface for DWARFLinker implementations.
+class DWARFLinkerBase {
+public:
+ virtual ~DWARFLinkerBase() = default;
+ using MessageHandlerTy = std::function<void(
+ const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
+ using ObjFileLoaderTy = std::function<ErrorOr<DWARFFile &>(
+ StringRef ContainerName, StringRef Path)>;
+ using InputVerificationHandlerTy =
+ std::function<void(const DWARFFile &File, llvm::StringRef Output)>;
+ using ObjectPrefixMapTy = std::map<std::string, std::string>;
+ using CompileUnitHandlerTy = function_ref<void(const DWARFUnit &Unit)>;
+ using TranslatorFuncTy = std::function<StringRef(StringRef)>;
+ using SwiftInterfacesMapTy = std::map<std::string, std::string>;
+ /// 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 c16c94d65c2fe6..c38a9906940ec5 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<void(
- const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
- using ObjFileLoaderTy = std::function<ErrorOr<DWARFFile &>(
- StringRef ContainerName, StringRef Path)>;
- using InputVerificationHandlerTy = std::function<void(const DWARFFile &File, llvm::StringRef Output)>;
- using ObjectPrefixMapTy = std::map<std::string, std::string>;
- using CompileUnitHandlerTy = function_ref<void(const DWARFUnit &Unit)>;
- using TranslatorFuncTy = std::function<StringRef(StringRef)>;
- using SwiftInterfacesMapTy = std::map<std::string, std::string>;
-
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 e55909f343116d..d0f4e211fac3ee 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 <string_view>
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<StringRef, StringEntry,
- parallel::PerThreadBumpPtrAllocator,
+ llvm::parallel::PerThreadBumpPtrAllocator,
StringPoolEntryInfo> {
public:
StringPool()
: ConcurrentHashTableByPtr<StringRef, StringEntry,
- parallel::PerThreadBumpPtrAllocator,
+ llvm::parallel::PerThreadBumpPtrAllocator,
StringPoolEntryInfo>(Allocator) {}
StringPool(size_t InitialSize)
: ConcurrentHashTableByPtr<StringRef, StringEntry,
- parallel::PerThreadBumpPtrAllocator,
+ llvm::parallel::PerThreadBumpPtrAllocator,
StringPoolEntryInfo>(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 6b1b2ae6d7e049..df862f60cb2f11 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 7084081ce61a43..f20e71781f46be 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<DWARFUnit> 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 283baa6090eb9a..ea22ff21820a98 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 f720c5e844b36e..73055a96d4a947 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 00000000000000..b173d42eb01539
--- /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 10967123a562e7..8d76c3bcf672e7 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<void(const Twine &, const DWARFDie &)> 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<void(const Twine &, const DWARFDie &)> ReportWarning) {
// LIFO work list.
std::vector<ContextWorklistItem> 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<DWARFFormValue> 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<uint64_t> 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<uint64_t> 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<bool, bool> 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<bool, bool> 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 06559bc38c86cc..1eb3a70a551359 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 015a4f9e8ac6bb..c9c8dddce9c443 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 3ec082f4ea0c24..020bbb06449d3a 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 5ec25cfe5fd26e..3af574c7056160 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 5e7f4d0c3166fd..bc3ea8669ece7e 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 def83f91bc6f31..c48f828609be2f 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 <atomic>
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 <typename T, size_t ItemsGroupSize = 512> 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 <typename T, size_t ItemsGroupSize = 512> class ArrayList {
std::atomic<ItemsGroup *> GroupsHead = nullptr;
std::atomic<ItemsGroup *> 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 b0f0b3910e586a..5d38062975135f 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 81fc57f7cabbb7..07ebd55e2c46fe 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 e18c0a15cefc63..6a6bd08570d7da 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 42bf00f55ff180..2341dbaa8c769f 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 355cfae3a64629..115167f0c7dc9a 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 d03336c1c11a36..89a33fe9419153 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 <typename DataT> class AccelTable;
class MCCodeEmitter;
-namespace dwarflinker_parallel {
+namespace dwarf_linker {
+namespace parallel {
using DebugNamesUnitsOffsets = std::vector<std::variant<MCSymbol *, uint64_t>>;
using CompUnitIDToIdx = DenseMap<unsigned, unsigned>;
@@ -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 269f24b1a13b9a..ad8d28a643174a 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>
-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>
+DWARFLinker::createLinker(MessageHandlerTy ErrorHandler,
+ MessageHandlerTy WarningHandler,
+ TranslatorFuncTy StringsTranslator) {
return std::make_unique<DWARFLinkerImpl>(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 3f0e7569027274..ffcf9f365aecab 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -21,7 +21,8 @@
#include <utility>
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<dwarf::Attribute> llvm::dwarflinker_parallel::getODRAttributes() {
+ArrayRef<dwarf::Attribute> 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 28fcc34d867dbd..abd978e7c0e4bb 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 <optional>
namespace llvm {
-namespace dwarflinker_parallel {
+namespace dwarf_linker {
+namespace parallel {
using OffsetToUnitTy = function_ref<CompileUnit *(uint64_t Offset)>;
@@ -730,7 +731,8 @@ class alignas(8) CompileUnit : public DwarfUnit {
/// infinite recursion.
ArrayRef<dwarf::Attribute> 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 31724770093d64..b641343ac808c7 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<StringRef(StringRef)>;
using MessageHandlerTy = std::function<void(
@@ -89,7 +90,9 @@ class LinkingGlobalData {
public:
/// Returns global per-thread allocator.
- parallel::PerThreadBumpPtrAllocator &getAllocator() { return Allocator; }
+ llvm::parallel::PerThreadBumpPtrAllocator &getAllocator() {
+ return Allocator;
+ }
/// Returns global string pool.
StringPool &getStringPool() { return Strings; }
@@ -145,7 +148,7 @@ class LinkingGlobalData {
}
protected:
- parallel::PerThreadBumpPtrAllocator Allocator;
+ llvm::parallel::PerThreadBumpPtrAllocator Allocator;
StringPool Strings;
TranslatorFuncTy Translator;
DWARFLinkerOptions Options;
@@ -153,7 +156,8 @@ class LinkingGlobalData {
MessageHandlerTy ErrorHandler;
};
-} // 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_DWARFLINKERGLOBALDATA_H
+#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
similarity index 91%
rename from llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp
rename to llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index c49b9ef0cdf989..bb59cbfdb3477a 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -15,8 +15,9 @@
#include "llvm/Support/Parallel.h"
#include "llvm/Support/ThreadPool.h"
-namespace llvm {
-namespace dwarflinker_parallel {
+using namespace llvm;
+using namespace dwarf_linker;
+using namespace dwarf_linker::parallel;
DWARFLinkerImpl::DWARFLinkerImpl(MessageHandlerTy ErrorHandler,
MessageHandlerTy WarningHandler,
@@ -182,7 +183,7 @@ Error DWARFLinkerImpl::link() {
CommonSections.setOutputFormat(GlobalFormat, GlobalEndianness);
if (!GlobalData.Options.NoODR && Language.has_value()) {
- parallel::TaskGroup TGroup;
+ llvm::parallel::TaskGroup TGroup;
TGroup.spawn([&]() {
ArtificialTypeUnit = std::make_unique<TypeUnit>(
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<LinkContext> &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<CompileUnit>(
- 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<CompileUnit>(
+ 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<CompileUnit> &CU) {
- linkSingleCompileUnit(*CU, ArtificialTypeUnit);
- });
+ // Link self-sufficient compile units and discover inter-connected compile
+ // units.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &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<bool> {
- HasNewInterconnectedCUs = false;
-
- // Load inter-connected units.
- parallelForEach(
- CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- if (CU->isInterconnectedCU()) {
- CU->maybeResetToLoadedStage();
- linkSingleCompileUnit(*CU, ArtificialTypeUnit,
- CompileUnit::Stage::Loaded);
- }
- });
-
- // Do liveness analysis for inter-connected units.
- parallelForEach(CompileUnits,
- [&](std::unique_ptr<CompileUnit> &CU) {
- linkSingleCompileUnit(
- *CU, ArtificialTypeUnit,
+ if (Error Err = finiteLoop([&]() -> Expected<bool> {
+ HasNewInterconnectedCUs = false;
+
+ // Load inter-connected units.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ if (CU->isInterconnectedCU()) {
+ CU->maybeResetToLoadedStage();
+ linkSingleCompileUnit(*CU, ArtificialTypeUnit,
+ CompileUnit::Stage::Loaded);
+ }
+ });
+
+ // Do liveness analysis for inter-connected units.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ linkSingleCompileUnit(*CU, ArtificialTypeUnit,
CompileUnit::Stage::LivenessAnalysisDone);
- });
-
- return HasNewInterconnectedCUs.load();
- }))
- return Err;
-
- // Update dependencies.
- if (Error Err = finiteLoop([&]() -> Expected<bool> {
- HasNewGlobalDependency = false;
- parallelForEach(
- CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- linkSingleCompileUnit(
- *CU, ArtificialTypeUnit,
- CompileUnit::Stage::UpdateDependenciesCompleteness);
- });
- return HasNewGlobalDependency.load();
- }))
- return Err;
- parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- if (CU->isInterconnectedCU() &&
- CU->getStage() == CompileUnit::Stage::LivenessAnalysisDone)
- CU->setStage(CompileUnit::Stage::UpdateDependenciesCompleteness);
- });
+ });
- // Assign type names.
- parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- linkSingleCompileUnit(*CU, ArtificialTypeUnit,
- CompileUnit::Stage::TypeNamesAssigned);
- });
+ return HasNewInterconnectedCUs.load();
+ }))
+ return Err;
- // Clone inter-connected units.
- parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- linkSingleCompileUnit(*CU, ArtificialTypeUnit,
- CompileUnit::Stage::Cloned);
- });
+ // Update dependencies.
+ if (Error Err = finiteLoop([&]() -> Expected<bool> {
+ HasNewGlobalDependency = false;
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ linkSingleCompileUnit(
+ *CU, ArtificialTypeUnit,
+ CompileUnit::Stage::UpdateDependenciesCompleteness);
+ });
+ return HasNewGlobalDependency.load();
+ }))
+ return Err;
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &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<CompileUnit> &CU) {
- linkSingleCompileUnit(*CU, ArtificialTypeUnit,
- CompileUnit::Stage::PatchesUpdated);
- });
+ // Assign type names.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ linkSingleCompileUnit(*CU, ArtificialTypeUnit,
+ CompileUnit::Stage::TypeNamesAssigned);
+ });
- // Release data.
- parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
- linkSingleCompileUnit(*CU, ArtificialTypeUnit,
- CompileUnit::Stage::Cleaned);
- });
- }
+ // Clone inter-connected units.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ linkSingleCompileUnit(*CU, ArtificialTypeUnit,
+ CompileUnit::Stage::Cloned);
+ });
+
+ // Update patches for inter-connected units.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
+ linkSingleCompileUnit(*CU, ArtificialTypeUnit,
+ CompileUnit::Stage::PatchesUpdated);
+ });
+
+ // Release data.
+ parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &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 60018eea121f20..b4331df5e323d7 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 9d5c213085c293..397411895a8e3e 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<uint16_t> 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 97e620eee0c424..0944de8d1315a9 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 b1da1900d65ef7..93def34aa4fda4 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 9640a8ee711eb0..36c24372e49420 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<uint64_t, DwarfUnit *>;
@@ -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 27c63fad712f13..545d04cfbe43d0 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<MCSubtargetInfo> 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 052eb6cf57d41e..04152e7f9f2b0e 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 b0b6ad3a1e8cfa..4a0d985c8aaa6b 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 0dc8de860a42e8..b592ce37937bc4 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 <utility>
namespace llvm {
-namespace dwarflinker_parallel {
+namespace dwarf_linker {
+namespace parallel {
template <typename T> class IndexedValuesMap {
public:
@@ -43,7 +44,8 @@ template <typename T> class IndexedValuesMap {
SmallVector<T> 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 730ae0f83d7b27..cd1205b60f85ba 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<uint8_t>(SectionKind)];
-}
+using namespace llvm;
+using namespace dwarf_linker;
+using namespace dwarf_linker::parallel;
-std::optional<DebugSectionKind> parseDebugTableName(llvm::StringRef SecName) {
+std::optional<DebugSectionKind>
+dwarf_linker::parallel::parseDebugTableName(llvm::StringRef SecName) {
return llvm::StringSwitch<std::optional<DebugSectionKind>>(
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 0f394b0810ea9c..b9df2228920a94 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 <cstdint>
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<size_t>(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<uint8_t>(SectionKind)];
+}
+
/// Recognise the table name and match it with the DebugSectionKind.
std::optional<DebugSectionKind> 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 b4c74d0adba970..858f224777dba7 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 a9b4478e33c40f..1554946c2c047b 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 c9dce4e94fb0dc..8465c0d77b9cb8 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 bbb3261027ce89..547532977262b1 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 <atomic>
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<TypeEntryBody>();
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<StringRef, TypeEntry,
- parallel::PerThreadBumpPtrAllocator,
- TypeEntryInfo> {
+class TypePool
+ : ConcurrentHashTableByPtr<StringRef, TypeEntry,
+ llvm::parallel::PerThreadBumpPtrAllocator,
+ TypeEntryInfo> {
public:
TypePool()
: ConcurrentHashTableByPtr<StringRef, TypeEntry,
- parallel::PerThreadBumpPtrAllocator,
+ llvm::parallel::PerThreadBumpPtrAllocator,
TypeEntryInfo>(Allocator) {
Root = TypeEntry::create("", Allocator);
Root->getValue().store(TypeEntryBody::create(Allocator));
@@ -116,7 +120,7 @@ class TypePool : ConcurrentHashTableByPtr<StringRef, TypeEntry,
TypeEntry *insert(StringRef Name) {
return ConcurrentHashTableByPtr<StringRef, TypeEntry,
- parallel::PerThreadBumpPtrAllocator,
+ llvm::parallel::PerThreadBumpPtrAllocator,
TypeEntryInfo>::insert(Name)
.first;
}
@@ -168,10 +172,11 @@ class TypePool : ConcurrentHashTableByPtr<StringRef, TypeEntry,
TypeEntry *Root = nullptr;
private:
- parallel::PerThreadBumpPtrAllocator Allocator;
+ llvm::parallel::PerThreadBumpPtrAllocator Allocator;
};
-} // end of namespace dwarflinker_parallel
-} // end namespace llvm
+} // end of namespace parallel
+} // end of namespace dwarf_linker
+} // end of namespace llvm
-#endif // LLVM_DWARFLINKERPARALLEL_TYPEPOOL_H
+#endif // LLVM_DWARFLINKER_PARALLEL_TYPEPOOL_H
diff --git a/llvm/lib/DWARFLinkerParallel/Utils.h b/llvm/lib/DWARFLinker/Parallel/Utils.h
similarity index 81%
rename from llvm/lib/DWARFLinkerParallel/Utils.h
rename to llvm/lib/DWARFLinker/Parallel/Utils.h
index 91f9dca46a82b1..3c05b2ea173d2b 100644
--- a/llvm/lib/DWARFLinkerParallel/Utils.h
+++ b/llvm/lib/DWARFLinker/Parallel/Utils.h
@@ -6,13 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIB_DWARFLINKERPARALLEL_UTILS_H
-#define LLVM_LIB_DWARFLINKERPARALLEL_UTILS_H
+#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H
+#define LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H
#include "llvm/Support/Error.h"
namespace llvm {
-namespace dwarflinker_parallel {
+namespace dwarf_linker {
+namespace parallel {
/// This function calls \p Iteration() until it returns false.
/// If number of iterations exceeds \p MaxCounter then an Error is returned.
@@ -34,7 +35,8 @@ inline Error finiteLoop(function_ref<Expected<bool>()> 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 fbff6b05e3a542..e8b0fe303aaef8 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 5a3486e6398d4c..00000000000000
--- 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<DWARFContext> Dwarf,
- std::unique_ptr<AddressesMap> 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 c612bfd9150c47..0e407f6fa1db43 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 33d053c745b0cb..4c6ad68d2e47af 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 <typename OutDwarfFile, typename AddressMap>
Error DwarfLinkerForBinary::emitRelocations(
- const DebugMap &DM,
- std::vector<ObjectWithRelocMap<OutDwarfFile>> &ObjectsForLinking) {
+ const DebugMap &DM, std::vector<ObjectWithRelocMap> &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 <typename OutDWARFFile, typename AddressesMap>
-ErrorOr<std::unique_ptr<OutDWARFFile>> DwarfLinkerForBinary::loadObject(
+ErrorOr<std::unique_ptr<DWARFFile>> DwarfLinkerForBinary::loadObject(
const DebugMapObject &Obj, const DebugMap &DebugMap,
remarks::RemarkLinker &RL,
std::shared_ptr<DwarfLinkerForBinaryRelocationMap> DLBRM) {
auto ErrorOrObj = loadObject(Obj, DebugMap.getTriple());
- std::unique_ptr<OutDWARFFile> Res;
+ std::unique_ptr<DWARFFile> Res;
if (ErrorOrObj) {
auto Context = DWARFContext::create(
@@ -285,9 +285,9 @@ ErrorOr<std::unique_ptr<OutDWARFFile>> DwarfLinkerForBinary::loadObject(
});
});
DLBRM->init(*Context);
- Res = std::make_unique<OutDWARFFile>(
+ Res = std::make_unique<DWARFFile>(
Obj.getObjectFilename(), std::move(Context),
- std::make_unique<AddressesMap>(*this, *ErrorOrObj, Obj, DLBRM),
+ std::make_unique<AddressManager>(*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
@@ -594,27 +594,21 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata(
bool DwarfLinkerForBinary::link(const DebugMap &Map) {
if (Options.DWARFLinkerType == DsymutilDWARFLinkerType::LLVM) {
- dwarflinker_parallel::DWARFLinker::OutputFileType DWARFLinkerOutputType;
+ parallel::DWARFLinker::OutputFileType DWARFLinkerOutputType;
switch (Options.FileType) {
- case DWARFLinker::OutputFileType::Object:
- DWARFLinkerOutputType =
- dwarflinker_parallel::DWARFLinker::OutputFileType::Object;
+ case DWARFLinkerBase::OutputFileType::Object:
+ DWARFLinkerOutputType = parallel::DWARFLinker::OutputFileType::Object;
break;
- case DWARFLinker::OutputFileType::Assembly:
- DWARFLinkerOutputType =
- dwarflinker_parallel::DWARFLinker::OutputFileType::Assembly;
+ case DWARFLinkerBase::OutputFileType::Assembly:
+ DWARFLinkerOutputType = parallel::DWARFLinker::OutputFileType::Assembly;
break;
}
- return linkImpl<dwarflinker_parallel::DWARFLinker,
- dwarflinker_parallel::DWARFFile,
- AddressManager<dwarflinker_parallel::AddressesMap>>(
- Map, DWARFLinkerOutputType);
+ return linkImpl<parallel::DWARFLinker>(Map, DWARFLinkerOutputType);
}
- return linkImpl<DWARFLinker, DWARFFile, AddressManager<AddressesMap>>(
- Map, Options.FileType);
+ return linkImpl<classic::DWARFLinker>(Map, Options.FileType);
}
template <typename Linker>
@@ -645,11 +639,11 @@ void setAcceleratorTables(Linker &GeneralLinker,
llvm_unreachable("All cases handled above!");
}
-template <typename Linker, typename OutDwarfFile, typename AddressMap>
+template <typename Linker>
bool DwarfLinkerForBinary::linkImpl(
const DebugMap &Map, typename Linker::OutputFileType ObjectType) {
- std::vector<ObjectWithRelocMap<OutDwarfFile>> ObjectsForLinking;
+ std::vector<ObjectWithRelocMap> ObjectsForLinking;
DebugMap DebugMap(Map.getTriple(), Map.getBinaryPath());
@@ -691,22 +685,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<std::mutex> 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<std::mutex> Guard(ErrorHandlerMutex);
+ if (Options.Verbose)
+ errs() << Output;
+ warn("input verification failed", File.FileName);
+ HasVerificationErrors = true;
+ });
auto Loader = [&](StringRef ContainerName,
- StringRef Path) -> ErrorOr<OutDwarfFile &> {
+ StringRef Path) -> ErrorOr<DWARFFile &> {
auto &Obj = DebugMap.addDebugMapObject(
Path, sys::TimePoint<std::chrono::seconds>(), MachO::N_OSO);
auto DLBRelocMap = std::make_shared<DwarfLinkerForBinaryRelocationMap>();
- if (ErrorOr<std::unique_ptr<OutDwarfFile>> ErrorOrObj =
- loadObject<OutDwarfFile, AddressMap>(Obj, DebugMap, RL,
- DLBRelocMap)) {
+ if (ErrorOr<std::unique_ptr<DWARFFile>> ErrorOrObj =
+ loadObject(Obj, DebugMap, RL, DLBRelocMap)) {
ObjectsForLinking.emplace_back(std::move(*ErrorOrObj), DLBRelocMap);
return *ObjectsForLinking.back().Object;
} else {
@@ -820,15 +814,15 @@ bool DwarfLinkerForBinary::linkImpl(
}
auto DLBRelocMap = std::make_shared<DwarfLinkerForBinaryRelocationMap>();
- if (ErrorOr<std::unique_ptr<OutDwarfFile>> ErrorOrObj =
- loadObject<OutDwarfFile, AddressMap>(*Obj, Map, RL, DLBRelocMap)) {
+ if (ErrorOr<std::unique_ptr<DWARFFile>> 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<OutDwarfFile>(Obj->getObjectFilename(), nullptr,
- nullptr),
+ {std::make_unique<DWARFFile>(Obj->getObjectFilename(), nullptr,
+ nullptr),
DLBRelocMap});
GeneralLinker->addObjectFile(*ObjectsForLinking.back().Object);
}
@@ -855,8 +849,7 @@ bool DwarfLinkerForBinary::linkImpl(
if (Options.NoOutput)
return true;
- if (Error E =
- emitRelocations<OutDwarfFile, AddressMap>(Map, ObjectsForLinking))
+ if (Error E = emitRelocations(Map, ObjectsForLinking))
return error(toString(std::move(E)));
if (Options.ResourceDir && !ParseableSwiftInterfaces.empty()) {
@@ -879,12 +872,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 <typename AddressesMapBase>
-void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
- findValidRelocsMachO(const object::SectionRef &Section,
- const object::MachOObjectFile &Obj,
- const DebugMapObject &DMO,
- std::vector<ValidReloc> &ValidRelocs) {
+void DwarfLinkerForBinary::AddressManager::findValidRelocsMachO(
+ const object::SectionRef &Section, const object::MachOObjectFile &Obj,
+ const DebugMapObject &DMO, std::vector<ValidReloc> &ValidRelocs) {
Expected<StringRef> ContentsOrErr = Section.getContents();
if (!ContentsOrErr) {
consumeError(ContentsOrErr.takeError());
@@ -961,8 +951,7 @@ void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
/// Dispatch the valid relocation finding logic to the
/// appropriate handler depending on the object file format.
-template <typename AddressesMapBase>
-bool DwarfLinkerForBinary::AddressManager<AddressesMapBase>::findValidRelocs(
+bool DwarfLinkerForBinary::AddressManager::findValidRelocs(
const object::SectionRef &Section, const object::ObjectFile &Obj,
const DebugMapObject &DMO, std::vector<ValidReloc> &Relocs) {
// Dispatch to the right handler depending on the file type.
@@ -987,10 +976,8 @@ bool DwarfLinkerForBinary::AddressManager<AddressesMapBase>::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 <typename AddressesMapBase>
-bool DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
- 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 +998,7 @@ bool DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
return FoundValidRelocs;
}
-template <typename AddressesMapBase>
-std::vector<ValidReloc>
-DwarfLinkerForBinary::AddressManager<AddressesMapBase>::getRelocations(
+std::vector<ValidReloc> DwarfLinkerForBinary::AddressManager::getRelocations(
const std::vector<ValidReloc> &Relocs, uint64_t StartPos, uint64_t EndPos) {
std::vector<ValidReloc> Res;
@@ -1030,9 +1015,7 @@ DwarfLinkerForBinary::AddressManager<AddressesMapBase>::getRelocations(
return Res;
}
-template <typename AddressesMapBase>
-void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::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 +1026,16 @@ void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::printReloc(
uint64_t(Mapping.BinaryAddress));
}
-template <typename AddressesMapBase>
-int64_t DwarfLinkerForBinary::AddressManager<AddressesMapBase>::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 <typename AddressesMapBase>
std::optional<int64_t>
-DwarfLinkerForBinary::AddressManager<AddressesMapBase>::hasValidRelocationAt(
+DwarfLinkerForBinary::AddressManager::hasValidRelocationAt(
const std::vector<ValidReloc> &AllRelocs, uint64_t StartOffset,
uint64_t EndOffset) {
std::vector<ValidReloc> Relocs =
@@ -1089,11 +1070,10 @@ getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
return std::make_pair(Offset, End);
}
-template <typename AddressesMapBase>
-std::optional<int64_t> DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
- getExprOpAddressRelocAdjustment(DWARFUnit &U,
- const DWARFExpression::Operation &Op,
- uint64_t StartOffset, uint64_t EndOffset) {
+std::optional<int64_t>
+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 +1096,9 @@ std::optional<int64_t> DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
return std::nullopt;
}
-template <typename AddressesMapBase>
-std::optional<int64_t> DwarfLinkerForBinary::AddressManager<
- AddressesMapBase>::getSubprogramRelocAdjustment(const DWARFDie &DIE) {
+std::optional<int64_t>
+DwarfLinkerForBinary::AddressManager::getSubprogramRelocAdjustment(
+ const DWARFDie &DIE) {
const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
std::optional<uint32_t> LowPcIdx =
@@ -1158,25 +1138,19 @@ std::optional<int64_t> DwarfLinkerForBinary::AddressManager<
}
}
-template <typename AddressesMapBase>
-std::optional<StringRef> DwarfLinkerForBinary::AddressManager<
- AddressesMapBase>::getLibraryInstallName() {
+std::optional<StringRef>
+DwarfLinkerForBinary::AddressManager::getLibraryInstallName() {
return LibInstallName;
}
-template <typename AddressesMapBase>
-uint64_t DwarfLinkerForBinary::AddressManager<AddressesMapBase>::relocate(
- const ValidReloc &Reloc) const {
+uint64_t
+DwarfLinkerForBinary::AddressManager::relocate(const ValidReloc &Reloc) const {
return Reloc.SymbolMapping.BinaryAddress + Reloc.Addend;
}
-template <typename AddressesMapBase>
-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<ValidReloc> InRelocs =
getRelocations(ValidDebugInfoRelocs, StartOffset, EndOffset);
if (IsDWARF5)
@@ -1185,10 +1159,8 @@ void DwarfLinkerForBinary::AddressManager<
IsDWARF5, InRelocs, OriginalUnitOffset, LinkedOffset);
}
-template <typename AddressesMapBase>
-void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
- updateRelocationsWithUnitOffset(uint64_t OriginalUnitOffset,
- uint64_t OutputUnitOffset) {
+void DwarfLinkerForBinary::AddressManager::updateRelocationsWithUnitOffset(
+ uint64_t OriginalUnitOffset, uint64_t OutputUnitOffset) {
DwarfLinkerRelocMap->updateRelocationsWithUnitOffset(OriginalUnitOffset,
OutputUnitOffset);
}
@@ -1200,8 +1172,7 @@ void DwarfLinkerForBinary::AddressManager<AddressesMapBase>::
/// monotonic \p BaseOffset values.
///
/// \returns whether any reloc has been applied.
-template <typename AddressesMapBase>
-bool DwarfLinkerForBinary::AddressManager<AddressesMapBase>::applyValidRelocs(
+bool DwarfLinkerForBinary::AddressManager::applyValidRelocs(
MutableArrayRef<char> Data, uint64_t BaseOffset, bool IsLittleEndian) {
std::vector<ValidReloc> Relocs = getRelocations(
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h
index 328cd9197d0d17..052c6a899fd76a 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 <optional>
namespace llvm {
+using namespace dwarf_linker;
+
namespace dsymutil {
/// DwarfLinkerForBinaryRelocationMap contains the logic to handle the
@@ -55,12 +53,12 @@ class DwarfLinkerForBinaryRelocationMap {
DwarfLinkerForBinaryRelocationMap() = default;
};
-template <typename OutDwarfFile> struct ObjectWithRelocMap {
+struct ObjectWithRelocMap {
ObjectWithRelocMap(
- std::unique_ptr<OutDwarfFile> Object,
+ std::unique_ptr<DWARFFile> Object,
std::shared_ptr<DwarfLinkerForBinaryRelocationMap> OutRelocs)
: Object(std::move(Object)), OutRelocs(OutRelocs) {}
- std::unique_ptr<OutDwarfFile> Object;
+ std::unique_ptr<DWARFFile> Object;
std::shared_ptr<DwarfLinkerForBinaryRelocationMap> OutRelocs;
};
@@ -104,8 +102,7 @@ class DwarfLinkerForBinary {
private:
/// Keeps track of relocations.
- template <typename AddressesMapBase>
- 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<const object::ObjectFile &> loadObject(const DebugMapObject &Obj,
const Triple &triple);
- template <typename OutDWARFFile, typename AddressesMap>
- ErrorOr<std::unique_ptr<OutDWARFFile>>
+ ErrorOr<std::unique_ptr<dwarf_linker::DWARFFile>>
loadObject(const DebugMapObject &Obj, const DebugMap &DebugMap,
remarks::RemarkLinker &RL,
std::shared_ptr<DwarfLinkerForBinaryRelocationMap> DLBRM);
@@ -264,14 +260,12 @@ class DwarfLinkerForBinary {
std::vector<MachOUtils::DwarfRelocationApplicationInfo>
&RelocationsToApply);
- template <typename Linker, typename OutDwarfFile, typename AddressMapBase>
+ template <typename Linker>
bool linkImpl(const DebugMap &Map,
typename Linker::OutputFileType ObjectType);
- template <typename OutDwarfFile, typename AddressMap>
- Error emitRelocations(
- const DebugMap &DM,
- std::vector<ObjectWithRelocMap<OutDwarfFile>> &ObjectsForLinking);
+ Error emitRelocations(const DebugMap &DM,
+ std::vector<ObjectWithRelocMap> &ObjectsForLinking);
raw_fd_ostream &OutFile;
BinaryHolder &BinHolder;
diff --git a/llvm/tools/dsymutil/LinkUtils.h b/llvm/tools/dsymutil/LinkUtils.h
index 0bf6d9aac1a3f3..97785dd872f5aa 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 <string>
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 2dd123318e00bd..a461d9e20a212a 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<DsymutilOptions> 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 b2585799b10c13..91b25207b4f728 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 02a94596ec7644..d6504992b56eb8 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 <vector>
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 <typename AddressMapBase>
-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 <typename Linker, typename OutDwarfFile, typename AddressMapBase>
+template <typename Linker>
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<std::unique_ptr<OutDwarfFile>> ObjectsForLinking(1);
+ std::vector<std::unique_ptr<DWARFFile>> ObjectsForLinking(1);
// Add object files to the DWARFLinker.
std::unique_ptr<DWARFContext> Context = DWARFContext::create(
@@ -360,11 +361,10 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options,
ReportWarn(Info.message(), "", nullptr);
});
});
- std::unique_ptr<ObjFileAddressMap<AddressMapBase>> AddressesMap(
- std::make_unique<ObjFileAddressMap<AddressMapBase>>(*Context, Options,
- File));
+ std::unique_ptr<ObjFileAddressMap> AddressesMap(
+ std::make_unique<ObjFileAddressMap>(*Context, Options, File));
- ObjectsForLinking[0] = std::make_unique<OutDwarfFile>(
+ ObjectsForLinking[0] = std::make_unique<DWARFFile>(
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<OutDwarfFile> &CurFile : ObjectsForLinking) {
+ for (std::unique_ptr<DWARFFile> &CurFile : ObjectsForLinking) {
SmallVector<StringRef> AccelTableNamesToReplace;
SmallVector<StringRef> 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<dwarflinker_parallel::DWARFLinker,
- dwarflinker_parallel::DWARFFile,
- dwarflinker_parallel::AddressesMap>(File, Options,
- OutStream);
+ return linkDebugInfoImpl<parallel::DWARFLinker>(File, Options, OutStream);
else
- return linkDebugInfoImpl<DWARFLinker, DWARFFile, AddressesMap>(
- File, Options, OutStream);
+ return linkDebugInfoImpl<classic::DWARFLinker>(File, Options, OutStream);
}
} // end of namespace dwarfutil
diff --git a/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp b/llvm/unittests/DWARFLinkerParallel/StringPoolTest.cpp
index 84199f696a59de..2612e763648b34 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 <cstdlib>
using namespace llvm;
-using namespace dwarflinker_parallel;
+using namespace dwarf_linker;
namespace {
More information about the llvm-commits
mailing list