mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-26 23:21:11 +00:00
[DWARFLinker][DWARFLinkerParallel][NFC] Refactor DWARFLinker&DWARFLinkerParallel to have a common library. Part 1. (#75925)
This patch creates DWARFLinkerBase library, places DWARFLinker code into DWARFLinker\Classic, places DWARFLinkerParallel into DWARFLinker\Parallel. updates BOLT to use new library. This patch is NFC.
This commit is contained in:
parent
4cb1d914ff
commit
2357e899cb
@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
|
||||
MC
|
||||
Object
|
||||
Support
|
||||
DWARFLinkerBase
|
||||
DWARFLinker
|
||||
AsmPrinter
|
||||
TargetParser
|
||||
|
@ -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 @@ private:
|
||||
|
||||
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);
|
||||
|
@ -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 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
} // end of namespace dwarflinker_parallel
|
||||
} // namespace dwarf_linker
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_DWARFLINKERPARALLEL_ADDRESSESMAP_H
|
||||
#endif // LLVM_DWARFLINKER_ADDRESSESMAP_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 @@ public:
|
||||
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 @@ public:
|
||||
///
|
||||
/// \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 @@ private:
|
||||
/// 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 @@ private:
|
||||
/// 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 @@ private:
|
||||
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
|
@ -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 @@ private:
|
||||
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
|
@ -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
|
@ -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 @@ private:
|
||||
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
|
@ -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 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace dwarflinker_parallel
|
||||
} // namespace dwarf_linker
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_DWARFLINKERPARALLEL_DWARFFILE_H
|
||||
#endif // LLVM_DWARFLINKER_DWARFFILE_H
|
100
llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
Normal file
100
llvm/include/llvm/DWARFLinker/DWARFLinkerBase.h
Normal file
@ -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
|
@ -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 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
/// 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
|
@ -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 @@ public:
|
||||
|
||||
/// \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
|
@ -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 {
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
24
llvm/lib/DWARFLinker/Classic/CMakeLists.txt
Normal file
24
llvm/lib/DWARFLinker/Classic/CMakeLists.txt
Normal file
@ -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
|
||||
)
|
@ -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;
|
@ -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";
|
@ -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.
|
||||
///
|
@ -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
|
@ -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
|
@ -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 @@ protected:
|
||||
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
|
@ -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 @@ protected:
|
||||
|
||||
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
|
@ -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
|
@ -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
|
@ -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 @@ protected:
|
||||
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
|
@ -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 @@ protected:
|
||||
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
|
@ -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
|
@ -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 @@ private:
|
||||
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
|
@ -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);
|
||||
}
|
@ -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};
|
@ -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 @@ private:
|
||||
/// 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
|
@ -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 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
parallel::PerThreadBumpPtrAllocator Allocator;
|
||||
llvm::parallel::PerThreadBumpPtrAllocator Allocator;
|
||||
StringPool Strings;
|
||||
TranslatorFuncTy Translator;
|
||||
DWARFLinkerOptions Options;
|
||||
@ -153,7 +156,8 @@ protected:
|
||||
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
|
@ -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();
|
||||
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);
|
||||
// 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()));
|
||||
// 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();
|
||||
}
|
||||
};
|
||||
// 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.
|
||||
// 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;
|
||||
|
||||
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) {
|
||||
linkSingleCompileUnit(*CU, ArtificialTypeUnit);
|
||||
if (CU->isInterconnectedCU() &&
|
||||
CU->getStage() == CompileUnit::Stage::LivenessAnalysisDone)
|
||||
CU->setStage(CompileUnit::Stage::UpdateDependenciesCompleteness);
|
||||
});
|
||||
|
||||
// Link all inter-connected units.
|
||||
if (HasNewInterconnectedCUs) {
|
||||
InterCUProcessingStarted = true;
|
||||
// Assign type names.
|
||||
parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
|
||||
linkSingleCompileUnit(*CU, ArtificialTypeUnit,
|
||||
CompileUnit::Stage::TypeNamesAssigned);
|
||||
});
|
||||
|
||||
if (Error Err = finiteLoop([&]() -> Expected<bool> {
|
||||
HasNewInterconnectedCUs = false;
|
||||
// Clone inter-connected units.
|
||||
parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
|
||||
linkSingleCompileUnit(*CU, ArtificialTypeUnit,
|
||||
CompileUnit::Stage::Cloned);
|
||||
});
|
||||
|
||||
// Load inter-connected units.
|
||||
parallelForEach(
|
||||
CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
|
||||
if (CU->isInterconnectedCU()) {
|
||||
CU->maybeResetToLoadedStage();
|
||||
linkSingleCompileUnit(*CU, ArtificialTypeUnit,
|
||||
CompileUnit::Stage::Loaded);
|
||||
}
|
||||
});
|
||||
// Update patches for inter-connected units.
|
||||
parallelForEach(CompileUnits, [&](std::unique_ptr<CompileUnit> &CU) {
|
||||
linkSingleCompileUnit(*CU, ArtificialTypeUnit,
|
||||
CompileUnit::Stage::PatchesUpdated);
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
// 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
|
@ -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 @@ public:
|
||||
}
|
||||
|
||||
/// 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 @@ protected:
|
||||
/// @}
|
||||
};
|
||||
|
||||
} // 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
|
@ -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([&]() {
|
@ -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 @@ private:
|
||||
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
|
@ -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
|
@ -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
|
@ -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 @@ private:
|
||||
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
|
@ -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
|
@ -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 @@ protected:
|
||||
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
|
@ -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 @@ protected:
|
||||
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
|
@ -11,22 +11,12 @@
|
||||
#include "DWARFLinkerTypeUnit.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace dwarflinker_parallel {
|
||||
using namespace llvm;
|
||||
using namespace dwarf_linker;
|
||||
using namespace dwarf_linker::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)];
|
||||
}
|
||||
|
||||
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
|
@ -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 @@ protected:
|
||||
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
|
@ -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 @@ protected:
|
||||
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
|
@ -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
|
@ -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 @@ protected:
|
||||
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
|
@ -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 @@ public:
|
||||
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 @@ protected:
|
||||
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 @@ public:
|
||||
|
||||
/// \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 @@ public:
|
||||
|
||||
TypeEntry *insert(StringRef Name) {
|
||||
return ConcurrentHashTableByPtr<StringRef, TypeEntry,
|
||||
parallel::PerThreadBumpPtrAllocator,
|
||||
llvm::parallel::PerThreadBumpPtrAllocator,
|
||||
TypeEntryInfo>::insert(Name)
|
||||
.first;
|
||||
}
|
||||
@ -168,10 +172,11 @@ protected:
|
||||
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
|
@ -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
|
@ -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"
|
@ -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) {}
|
@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
|
||||
AsmPrinter
|
||||
CodeGen
|
||||
CodeGenTypes
|
||||
DWARFLinkerBase
|
||||
DWARFLinker
|
||||
DWARFLinkerParallel
|
||||
DebugInfoDWARF
|
||||
|
@ -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
|
||||
@ -593,28 +593,10 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata(
|
||||
}
|
||||
|
||||
bool DwarfLinkerForBinary::link(const DebugMap &Map) {
|
||||
if (Options.DWARFLinkerType == DsymutilDWARFLinkerType::LLVM) {
|
||||
dwarflinker_parallel::DWARFLinker::OutputFileType DWARFLinkerOutputType;
|
||||
switch (Options.FileType) {
|
||||
case DWARFLinker::OutputFileType::Object:
|
||||
DWARFLinkerOutputType =
|
||||
dwarflinker_parallel::DWARFLinker::OutputFileType::Object;
|
||||
break;
|
||||
if (Options.DWARFLinkerType == DsymutilDWARFLinkerType::LLVM)
|
||||
return linkImpl<parallel::DWARFLinker>(Map, Options.FileType);
|
||||
|
||||
case DWARFLinker::OutputFileType::Assembly:
|
||||
DWARFLinkerOutputType =
|
||||
dwarflinker_parallel::DWARFLinker::OutputFileType::Assembly;
|
||||
break;
|
||||
}
|
||||
|
||||
return linkImpl<dwarflinker_parallel::DWARFLinker,
|
||||
dwarflinker_parallel::DWARFFile,
|
||||
AddressManager<dwarflinker_parallel::AddressesMap>>(
|
||||
Map, DWARFLinkerOutputType);
|
||||
}
|
||||
|
||||
return linkImpl<DWARFLinker, DWARFFile, AddressManager<AddressesMap>>(
|
||||
Map, Options.FileType);
|
||||
return linkImpl<classic::DWARFLinker>(Map, Options.FileType);
|
||||
}
|
||||
|
||||
template <typename Linker>
|
||||
@ -645,11 +627,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 +673,22 @@ bool DwarfLinkerForBinary::linkImpl(
|
||||
GeneralLinker->setNumThreads(Options.Threads);
|
||||
GeneralLinker->setPrependPath(Options.PrependPath);
|
||||
GeneralLinker->setKeepFunctionForStatic(Options.KeepFunctionForStatic);
|
||||
GeneralLinker->setInputVerificationHandler([&](const OutDwarfFile &File, llvm::StringRef Output) {
|
||||
std::lock_guard<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 +802,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 +837,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 +860,9 @@ bool DwarfLinkerForBinary::linkImpl(
|
||||
/// Iterate over the relocations of the given \p Section and
|
||||
/// store the ones that correspond to debug map entries into the
|
||||
/// ValidRelocs array.
|
||||
template <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 +939,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 +964,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 +986,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 +1003,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 +1014,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 +1058,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 +1084,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 +1126,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 +1147,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 +1160,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(
|
||||
|
@ -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 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
/// 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 @@ private:
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
|
||||
AllTargetsDescs
|
||||
AllTargetsInfos
|
||||
CodeGenTypes
|
||||
DWARFLinkerBase
|
||||
DWARFLinker
|
||||
DWARFLinkerParallel
|
||||
DebugInfoDWARF
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user