diff options
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-dwarfutil')
4 files changed, 31 insertions, 14 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp index d6504992b56e..bd17f3c4a659 100644 --- a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp +++ b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp @@ -80,8 +80,8 @@ public: // should be renamed into has valid address ranges bool hasValidRelocs() override { return HasValidAddressRanges; } - std::optional<int64_t> - getSubprogramRelocAdjustment(const DWARFDie &DIE) override { + std::optional<int64_t> getSubprogramRelocAdjustment(const DWARFDie &DIE, + bool Verbose) override { assert((DIE.getTag() == dwarf::DW_TAG_subprogram || DIE.getTag() == dwarf::DW_TAG_label) && "Wrong type of input die"); @@ -101,7 +101,7 @@ public: std::optional<int64_t> getExprOpAddressRelocAdjustment(DWARFUnit &U, const DWARFExpression::Operation &Op, - uint64_t, uint64_t) override { + uint64_t, uint64_t, bool Verbose) override { switch (Op.getCode()) { default: { assert(false && "Specified operation does not have address operand"); @@ -336,9 +336,26 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, Linker::createLinker(ReportErr, ReportWarn); Triple TargetTriple = File.makeTriple(); - if (Error Err = DebugInfoLinker->createEmitter( - TargetTriple, Linker::OutputFileType::Object, OutStream)) - return Err; + std::unique_ptr<classic::DwarfStreamer> Streamer; + if (Expected<std::unique_ptr<classic::DwarfStreamer>> StreamerOrErr = + classic::DwarfStreamer::createStreamer( + TargetTriple, Linker::OutputFileType::Object, OutStream, nullptr, + ReportWarn)) + Streamer = std::move(*StreamerOrErr); + else + return StreamerOrErr.takeError(); + + if constexpr (std::is_same<Linker, + dwarf_linker::parallel::DWARFLinker>::value) { + DebugInfoLinker->setOutputDWARFHandler( + TargetTriple, + [&](std::shared_ptr<dwarf_linker::parallel::SectionDescriptorBase> + Section) { + Streamer->emitSectionContents(Section->getContents(), + Section->getKind()); + }); + } else + DebugInfoLinker->setOutputDWARFEmitter(Streamer.get()); DebugInfoLinker->setEstimatedObjfilesAmount(1); DebugInfoLinker->setNumThreads(Options.NumThreads); @@ -445,13 +462,13 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options, if (Error Err = DebugInfoLinker->link()) return Err; - DebugInfoLinker->getEmitter()->finish(); + Streamer->finish(); return Error::success(); } Error linkDebugInfo(object::ObjectFile &File, const Options &Options, raw_pwrite_stream &OutStream) { - if (Options.UseLLVMDWARFLinker) + if (Options.UseDWARFLinkerParallel) return linkDebugInfoImpl<parallel::DWARFLinker>(File, Options, OutStream); else return linkDebugInfoImpl<classic::DWARFLinker>(File, Options, OutStream); diff --git a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.h b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.h index caa35d3c4572..e3cfa421da91 100644 --- a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.h +++ b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.h @@ -40,7 +40,7 @@ struct Options { bool Verbose = false; int NumThreads = 0; bool Verify = false; - bool UseLLVMDWARFLinker = false; + bool UseDWARFLinkerParallel = false; DwarfUtilAccelKind AccelTableKind = DwarfUtilAccelKind::None; std::string getSeparateDebugFileName() const { diff --git a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.td b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.td index 26b9ac678b6a..85606bd4d58d 100644 --- a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.td +++ b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/Options.td @@ -22,7 +22,7 @@ def h : Flag<["-"], "h">, def linker: Separate<["--", "-"], "linker">, MetaVarName<"<DWARF linker type>">, - HelpText<"Specify the desired type of DWARF linker. Defaults to 'apple'">; + HelpText<"Specify the desired type of DWARF linker. Defaults to 'classic'">; def: Joined<["--", "-"], "linker=">, Alias<linker>; defm odr_deduplication : BB<"odr-deduplication", diff --git a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp index e09060abb626..7b777b1845f8 100644 --- a/contrib/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp +++ b/contrib/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp @@ -118,10 +118,10 @@ static Error validateAndSetOptions(opt::InputArgList &Args, Options &Options) { if (opt::Arg *LinkerKind = Args.getLastArg(OPT_linker)) { StringRef S = LinkerKind->getValue(); - if (S == "apple") - Options.UseLLVMDWARFLinker = false; - else if (S == "llvm") - Options.UseLLVMDWARFLinker = true; + if (S == "classic") + Options.UseDWARFLinkerParallel = false; + else if (S == "parallel") + Options.UseDWARFLinkerParallel = true; else return createStringError( std::errc::invalid_argument, |
