[llvm] [dsymutil] Remove paper trail warnings (PR #67041)

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 22 09:01:50 PDT 2023


https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/67041

>From c8cd1c9fe21372a14fcfd687c9ce37b81c0be07a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Thu, 21 Sep 2023 09:50:31 -0700
Subject: [PATCH] [dsymutil] Remove paper trail warnings

Remove the paper trail warning from dsymutil and the DWARF linker. The
original purpose of this functionality was to leave a paper trail in the
output artifact about missing object files. The current implementation
however has diverged and is the source of a pretty serious bug:

  - In the debug map parser, missing object files are not the only
    warnings we emit. When paper trail warnings are enabled, all of them
    end up in the dSYM which wasn't the goal.
  - When warnings are associated with a object file in the debug map, it
    is skipped by the DWARF linker. This only makes sense if the object
    file is missing and is obviously incorrect for any other type of
    warning (such as a missing symbol).

The combination of the two means that we can generate broken DWARF when
the feature is enabled. AFAIK it was only used by Apple and nobody I
spoke to has relied on it, so rather than fixing the broken behavior I
propose we remove it.
---
 llvm/docs/CommandGuide/dsymutil.rst           |   7 -
 llvm/include/llvm/DWARFLinker/DWARFLinker.h   |  16 +-
 llvm/include/llvm/DWARFLinker/DWARFStreamer.h |   3 -
 .../llvm/DWARFLinkerParallel/DWARFFile.h      |   4 -
 llvm/lib/DWARFLinker/DWARFLinker.cpp          |  66 --------
 llvm/lib/DWARFLinker/DWARFStreamer.cpp        |  12 --
 llvm/lib/DWARFLinkerParallel/DWARFFile.cpp    |   3 +-
 .../DWARFLinkerParallel/DWARFLinkerImpl.cpp   | 146 +++---------------
 .../lib/DWARFLinkerParallel/DWARFLinkerImpl.h |   3 -
 .../dsymutil/X86/papertrail-warnings.test     |  32 ----
 llvm/test/tools/dsymutil/cmdline.test         |   1 -
 llvm/tools/dsymutil/DwarfLinkerForBinary.cpp  |   4 +-
 llvm/tools/dsymutil/MachODebugMapParser.cpp   |  20 +--
 llvm/tools/dsymutil/Options.td                |   4 -
 llvm/tools/dsymutil/dsymutil.cpp              |  14 +-
 llvm/tools/dsymutil/dsymutil.h                |   3 +-
 llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp |   6 +-
 17 files changed, 31 insertions(+), 313 deletions(-)
 delete mode 100644 llvm/test/tools/dsymutil/X86/papertrail-warnings.test

diff --git a/llvm/docs/CommandGuide/dsymutil.rst b/llvm/docs/CommandGuide/dsymutil.rst
index 0cc2a472bbd0696..02243e227a24d4a 100644
--- a/llvm/docs/CommandGuide/dsymutil.rst
+++ b/llvm/docs/CommandGuide/dsymutil.rst
@@ -100,13 +100,6 @@ OPTIONS
  Specifies an alternate ``path`` to place the dSYM bundle. The default dSYM
  bundle path is created by appending ``.dSYM`` to the executable name.
 
-.. option:: --papertrail
-
- When running dsymutil as part of your build system, it can be desirable for
- warnings to be part of the end product, rather than just being emitted to the
- output stream. When enabled warnings are embedded in the linked DWARF debug
- information.
-
 .. option:: --remarks-drop-without-debug
 
  Drop remarks without valid debug locations. Without this flags, all remarks are kept.
diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index 5ca6f2e4e4e06e0..8489538e9b9f7a1 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -99,9 +99,6 @@ class DwarfEmitter {
 public:
   virtual ~DwarfEmitter();
 
-  /// Emit DIE containing warnings.
-  virtual void emitPaperTrailWarningsDie(DIE &Die) = 0;
-
   /// Emit section named SecName with data SecData.
   virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0;
 
@@ -272,11 +269,9 @@ class DWARFFile {
 public:
   using UnloadCallbackTy = std::function<void(StringRef FileName)>;
   DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
-            std::unique_ptr<AddressesMap> Addresses,
-            const std::vector<std::string> &Warnings,
-            UnloadCallbackTy = nullptr)
+            std::unique_ptr<AddressesMap> Addresses, UnloadCallbackTy = nullptr)
       : FileName(Name), Dwarf(std::move(Dwarf)),
-        Addresses(std::move(Addresses)), Warnings(Warnings) {}
+        Addresses(std::move(Addresses)) {}
 
   /// The object file name.
   StringRef FileName;
@@ -286,9 +281,6 @@ class DWARFFile {
 
   /// Helpful address information(list of valid address ranges, relocations).
   std::unique_ptr<AddressesMap> Addresses;
-
-  /// Warnings for this object file.
-  const std::vector<std::string> &Warnings;
 };
 
 typedef std::map<std::string, std::string> swiftInterfacesMap;
@@ -508,10 +500,6 @@ class DWARFLinker {
       ErrorHandler(Warning, File.FileName, DIE);
   }
 
-  /// Emit warnings as Dwarf compile units to leave a trail after linking.
-  bool emitPaperTrailWarnings(const DWARFFile &File,
-                              OffsetsStringPool &StringPool);
-
   void copyInvariantDebugSection(DWARFContext &Dwarf);
 
   /// Keep information for referenced clang module: already loaded DWARF info
diff --git a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
index b95abfbefa1065b..63e4b28a8d2c997 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h
@@ -72,9 +72,6 @@ class DwarfStreamer : public DwarfEmitter {
   void emitAbbrevs(const std::vector<std::unique_ptr<DIEAbbrev>> &Abbrevs,
                    unsigned DwarfVersion) override;
 
-  /// Emit DIE containing warnings.
-  void emitPaperTrailWarningsDie(DIE &Die) override;
-
   /// Emit contents of section SecName From Obj.
   void emitSectionContents(StringRef SecData, StringRef SecName) override;
 
diff --git a/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h b/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h
index e48150ef2339e2f..c320530569bb052 100644
--- a/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h
+++ b/llvm/include/llvm/DWARFLinkerParallel/DWARFFile.h
@@ -29,7 +29,6 @@ class DWARFFile {
 
   DWARFFile(StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
             std::unique_ptr<AddressesMap> Addresses,
-            const std::vector<std::string> &Warnings,
             UnloadCallbackTy UnloadFunc = nullptr);
 
   /// Object file name.
@@ -41,9 +40,6 @@ class DWARFFile {
   /// Helpful address information(list of valid address ranges, relocations).
   std::unique_ptr<AddressesMap> Addresses;
 
-  /// Warnings for object file.
-  const std::vector<std::string> &Warnings;
-
   /// Callback to the module keeping object file to unload.
   UnloadCallbackTy UnloadFunc;
 
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 35e5cefc3877060..5ed4923dc0125a6 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -2584,69 +2584,6 @@ uint64_t DWARFLinker::DIECloner::cloneAllCompileUnits(
   return OutputDebugInfoSize - StartOutputDebugInfoSize;
 }
 
-bool DWARFLinker::emitPaperTrailWarnings(const DWARFFile &File,
-                                         OffsetsStringPool &StringPool) {
-
-  if (File.Warnings.empty())
-    return false;
-
-  DIE *CUDie = DIE::get(DIEAlloc, dwarf::DW_TAG_compile_unit);
-  CUDie->setOffset(11);
-  StringRef Producer;
-  StringRef WarningHeader;
-
-  switch (DwarfLinkerClientID) {
-  case DwarfLinkerClient::Dsymutil:
-    Producer = StringPool.internString("dsymutil");
-    WarningHeader = "dsymutil_warning";
-    break;
-
-  default:
-    Producer = StringPool.internString("dwarfopt");
-    WarningHeader = "dwarfopt_warning";
-    break;
-  }
-
-  StringRef FileName = StringPool.internString(File.FileName);
-  CUDie->addValue(DIEAlloc, dwarf::DW_AT_producer, dwarf::DW_FORM_strp,
-                  DIEInteger(StringPool.getStringOffset(Producer)));
-  DIEBlock *String = new (DIEAlloc) DIEBlock();
-  DIEBlocks.push_back(String);
-  for (auto &C : FileName)
-    String->addValue(DIEAlloc, dwarf::Attribute(0), dwarf::DW_FORM_data1,
-                     DIEInteger(C));
-  String->addValue(DIEAlloc, dwarf::Attribute(0), dwarf::DW_FORM_data1,
-                   DIEInteger(0));
-
-  CUDie->addValue(DIEAlloc, dwarf::DW_AT_name, dwarf::DW_FORM_string, String);
-  for (const auto &Warning : File.Warnings) {
-    DIE &ConstDie = CUDie->addChild(DIE::get(DIEAlloc, dwarf::DW_TAG_constant));
-    ConstDie.addValue(DIEAlloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp,
-                      DIEInteger(StringPool.getStringOffset(WarningHeader)));
-    ConstDie.addValue(DIEAlloc, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag,
-                      DIEInteger(1));
-    ConstDie.addValue(DIEAlloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_strp,
-                      DIEInteger(StringPool.getStringOffset(Warning)));
-  }
-  unsigned Size = 4 /* FORM_strp */ + FileName.size() + 1 +
-                  File.Warnings.size() * (4 + 1 + 4) + 1 /* End of children */;
-  DIEAbbrev Abbrev = CUDie->generateAbbrev();
-  assignAbbrev(Abbrev);
-  CUDie->setAbbrevNumber(Abbrev.getNumber());
-  Size += getULEB128Size(Abbrev.getNumber());
-  // Abbreviation ordering needed for classic compatibility.
-  for (auto &Child : CUDie->children()) {
-    Abbrev = Child.generateAbbrev();
-    assignAbbrev(Abbrev);
-    Child.setAbbrevNumber(Abbrev.getNumber());
-    Size += getULEB128Size(Abbrev.getNumber());
-  }
-  CUDie->setSize(Size);
-  TheDwarfEmitter->emitPaperTrailWarningsDie(*CUDie);
-
-  return true;
-}
-
 void DWARFLinker::copyInvariantDebugSection(DWARFContext &Dwarf) {
   TheDwarfEmitter->emitSectionContents(Dwarf.getDWARFObj().getLocSection().Data,
                                        "debug_loc");
@@ -2711,9 +2648,6 @@ Error DWARFLinker::link() {
         outs() << "OBJECT FILE: " << OptContext.File.FileName << "\n";
     }
 
-    if (emitPaperTrailWarnings(OptContext.File, DebugStrPool))
-      continue;
-
     if (!OptContext.File.Dwarf)
       continue;
 
diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
index 4d5eef54408edb8..3bcc5a065a04718 100644
--- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
@@ -234,18 +234,6 @@ void DwarfStreamer::emitSectionContents(StringRef SecData, StringRef SecName) {
   }
 }
 
-/// Emit DIE containing warnings.
-void DwarfStreamer::emitPaperTrailWarningsDie(DIE &Die) {
-  switchToDebugInfoSection(/* Version */ 2);
-  auto &Asm = getAsmPrinter();
-  Asm.emitInt32(11 + Die.getSize() - 4);
-  Asm.emitInt16(2);
-  Asm.emitInt32(0);
-  Asm.emitInt8(MC->getTargetTriple().isArch64Bit() ? 8 : 4);
-  DebugInfoSectionSize += 11;
-  emitDIE(Die);
-}
-
 /// Emit the debug_str section stored in \p Pool.
 void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) {
   Asm->OutStreamer->switchSection(MOFI->getDwarfStrSection());
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp b/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp
index 86c7e816ead8fe0..5a3486e6398d4c5 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp
+++ b/llvm/lib/DWARFLinkerParallel/DWARFFile.cpp
@@ -12,7 +12,6 @@
 llvm::dwarflinker_parallel::DWARFFile::DWARFFile(
     StringRef Name, std::unique_ptr<DWARFContext> Dwarf,
     std::unique_ptr<AddressesMap> Addresses,
-    const std::vector<std::string> &Warnings,
     DWARFFile::UnloadCallbackTy UnloadFunc)
     : FileName(Name), Dwarf(std::move(Dwarf)), Addresses(std::move(Addresses)),
-      Warnings(Warnings), UnloadFunc(UnloadFunc) {}
+      UnloadFunc(UnloadFunc) {}
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp
index 799910a6ed9fba7..34e09fada1dfbe3 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp
@@ -371,27 +371,26 @@ Error DWARFLinkerImpl::LinkContext::loadClangModule(
 
 Error DWARFLinkerImpl::LinkContext::link() {
   InterCUProcessingStarted = false;
-  if (InputDWARFFile.Warnings.empty()) {
-    if (!InputDWARFFile.Dwarf)
-      return Error::success();
+  if (!InputDWARFFile.Dwarf)
+    return Error::success();
 
-    // Preload macro tables, as they can't be loaded asynchronously.
-    InputDWARFFile.Dwarf->getDebugMacinfo();
-    InputDWARFFile.Dwarf->getDebugMacro();
+  // Preload macro tables, as they can't be loaded asynchronously.
+  InputDWARFFile.Dwarf->getDebugMacinfo();
+  InputDWARFFile.Dwarf->getDebugMacro();
 
-    // Link modules compile units first.
-    parallelForEach(ModulesCompileUnits, [&](RefModuleUnit &RefModule) {
-      linkSingleCompileUnit(*RefModule.Unit);
-    });
+  // Link modules compile units first.
+  parallelForEach(ModulesCompileUnits, [&](RefModuleUnit &RefModule) {
+    linkSingleCompileUnit(*RefModule.Unit);
+  });
 
-    // Check for live relocations. If there is no any live relocation then we
-    // can skip entire object file.
-    if (!GlobalData.getOptions().UpdateIndexTablesOnly &&
-        !InputDWARFFile.Addresses->hasValidRelocs()) {
-      if (GlobalData.getOptions().Verbose)
-        outs() << "No valid relocations found. Skipping.\n";
-      return Error::success();
-    }
+  // Check for live relocations. If there is no any live relocation then we
+  // can skip entire object file.
+  if (!GlobalData.getOptions().UpdateIndexTablesOnly &&
+      !InputDWARFFile.Addresses->hasValidRelocs()) {
+    if (GlobalData.getOptions().Verbose)
+      outs() << "No valid relocations found. Skipping.\n";
+    return Error::success();
+  }
 
     OriginalDebugInfoSize = getInputDebugInfoSize();
 
@@ -460,21 +459,8 @@ Error DWARFLinkerImpl::LinkContext::link() {
         linkSingleCompileUnit(*CU, CompileUnit::Stage::Cleaned);
       });
     }
-  }
 
-  if (!InputDWARFFile.Warnings.empty()) {
-    // Create compile unit with paper trail warnings.
-
-    Error ResultErr = Error::success();
-    // We use task group here as PerThreadBumpPtrAllocator should be called from
-    // the threads created by ThreadPoolExecutor.
-    parallel::TaskGroup TGroup;
-    TGroup.spawn([&]() {
-      if (Error Err = cloneAndEmitPaperTrails())
-        ResultErr = std::move(Err);
-    });
-    return ResultErr;
-  } else if (GlobalData.getOptions().UpdateIndexTablesOnly) {
+  if (GlobalData.getOptions().UpdateIndexTablesOnly) {
     // Emit Invariant sections.
 
     if (Error Err = emitInvariantSections())
@@ -715,102 +701,6 @@ void DWARFLinkerImpl::LinkContext::emitFDE(uint32_t CIEOffset,
   Section.OS.write(FDEBytes.data(), FDEBytes.size());
 }
 
-Error DWARFLinkerImpl::LinkContext::cloneAndEmitPaperTrails() {
-  CompileUnits.emplace_back(std::make_unique<CompileUnit>(
-      GlobalData, UniqueUnitID.fetch_add(1), "", InputDWARFFile,
-      getUnitForOffset, Format, Endianness));
-
-  CompileUnit &CU = *CompileUnits.back();
-
-  BumpPtrAllocator Allocator;
-
-  DIEGenerator ParentGenerator(Allocator, CU);
-
-  SectionDescriptor &DebugInfoSection =
-      CU.getOrCreateSectionDescriptor(DebugSectionKind::DebugInfo);
-  OffsetsPtrVector PatchesOffsets;
-
-  uint64_t CurrentOffset = CU.getDebugInfoHeaderSize();
-  DIE *CUDie =
-      ParentGenerator.createDIE(dwarf::DW_TAG_compile_unit, CurrentOffset);
-  CU.setOutUnitDIE(CUDie);
-
-  DebugInfoSection.notePatchWithOffsetUpdate(
-      DebugStrPatch{{CurrentOffset},
-                    GlobalData.getStringPool().insert("dsymutil").first},
-      PatchesOffsets);
-  CurrentOffset += ParentGenerator
-                       .addStringPlaceholderAttribute(dwarf::DW_AT_producer,
-                                                      dwarf::DW_FORM_strp)
-                       .second;
-
-  CurrentOffset +=
-      ParentGenerator
-          .addInplaceString(dwarf::DW_AT_name, InputDWARFFile.FileName)
-          .second;
-
-  size_t SizeAbbrevNumber = ParentGenerator.finalizeAbbreviations(true);
-  CurrentOffset += SizeAbbrevNumber;
-  for (uint64_t *OffsetPtr : PatchesOffsets)
-    *OffsetPtr += SizeAbbrevNumber;
-  for (const auto &Warning : CU.getContaingFile().Warnings) {
-    PatchesOffsets.clear();
-    DIEGenerator ChildGenerator(Allocator, CU);
-
-    DIE *ChildDie =
-        ChildGenerator.createDIE(dwarf::DW_TAG_constant, CurrentOffset);
-    ParentGenerator.addChild(ChildDie);
-
-    DebugInfoSection.notePatchWithOffsetUpdate(
-        DebugStrPatch{
-            {CurrentOffset},
-            GlobalData.getStringPool().insert("dsymutil_warning").first},
-        PatchesOffsets);
-    CurrentOffset += ChildGenerator
-                         .addStringPlaceholderAttribute(dwarf::DW_AT_name,
-                                                        dwarf::DW_FORM_strp)
-                         .second;
-
-    CurrentOffset +=
-        ChildGenerator
-            .addScalarAttribute(dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1)
-            .second;
-
-    DebugInfoSection.notePatchWithOffsetUpdate(
-        DebugStrPatch{{CurrentOffset},
-                      GlobalData.getStringPool().insert(Warning).first},
-        PatchesOffsets);
-    CurrentOffset += ChildGenerator
-                         .addStringPlaceholderAttribute(
-                             dwarf::DW_AT_const_value, dwarf::DW_FORM_strp)
-                         .second;
-
-    SizeAbbrevNumber = ChildGenerator.finalizeAbbreviations(false);
-
-    CurrentOffset += SizeAbbrevNumber;
-    for (uint64_t *OffsetPtr : PatchesOffsets)
-      *OffsetPtr += SizeAbbrevNumber;
-
-    ChildDie->setSize(CurrentOffset - ChildDie->getOffset());
-  }
-
-  CurrentOffset += 1; // End of children
-  CUDie->setSize(CurrentOffset - CUDie->getOffset());
-
-  uint64_t UnitSize = 0;
-  UnitSize += CU.getDebugInfoHeaderSize();
-  UnitSize += CUDie->getSize();
-  CU.setUnitSize(UnitSize);
-
-  if (GlobalData.getOptions().NoOutput)
-    return Error::success();
-
-  if (Error Err = CU.emitDebugInfo(*TargetTriple))
-    return Err;
-
-  return CU.emitAbbreviations();
-}
-
 void DWARFLinkerImpl::glueCompileUnitsAndWriteToTheOutput() {
   if (GlobalData.getOptions().NoOutput)
     return;
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h
index c04eb8467e4a89d..bee212ba95ec3bc 100644
--- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h
+++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h
@@ -294,9 +294,6 @@ class DWARFLinkerImpl : public DWARFLinker {
     void emitFDE(uint32_t CIEOffset, uint32_t AddrSize, uint64_t Address,
                  StringRef FDEBytes, SectionDescriptor &Section);
 
-    /// Clone and emit paper trails.
-    Error cloneAndEmitPaperTrails();
-
     std::function<CompileUnit *(uint64_t)> getUnitForOffset =
         [&](uint64_t Offset) -> CompileUnit * {
       auto CU = llvm::upper_bound(
diff --git a/llvm/test/tools/dsymutil/X86/papertrail-warnings.test b/llvm/test/tools/dsymutil/X86/papertrail-warnings.test
deleted file mode 100644
index 69c851a335ad692..000000000000000
--- a/llvm/test/tools/dsymutil/X86/papertrail-warnings.test
+++ /dev/null
@@ -1,32 +0,0 @@
-RUN: env RC_DEBUG_OPTIONS=1 dsymutil -f %p/../Inputs/basic.macho.x86_64 -o - | llvm-dwarfdump -v - | FileCheck -DMSG=%errc_ENOENT %s
-
-RUN: env RC_DEBUG_OPTIONS=1 dsymutil --linker llvm -f %p/../Inputs/basic.macho.x86_64 -o - | llvm-dwarfdump -v - | FileCheck -DMSG=%errc_ENOENT %s
-
-CHECK: .debug_info contents:
-CHECK:  Compile Unit:
-CHECK:  DW_TAG_compile_unit [1] *
-CHECK:    DW_AT_producer {{.*}}"dsymutil
-CHECK:    DW_AT_name {{.*}}"/Inputs/basic1.macho.x86_64.o"
-CHECK:    DW_TAG_constant [2]
-CHECK:      DW_AT_name {{.*}}"dsymutil_warning"
-CHECK:      DW_AT_artificial [DW_FORM_flag]	(0x01)
-CHECK:      DW_AT_const_value {{.*}}"unable to open object file: [[MSG]]"
-CHECK:    NULL
-CHECK:  Compile Unit:
-CHECK:  DW_TAG_compile_unit [1] *
-CHECK:    DW_AT_producer {{.*}}"dsymutil
-CHECK:    DW_AT_name {{.*}}"/Inputs/basic2.macho.x86_64.o"
-CHECK:    DW_TAG_constant [2]
-CHECK:      DW_AT_name {{.*}}"dsymutil_warning"
-CHECK:      DW_AT_artificial [DW_FORM_flag]	(0x01)
-CHECK:      DW_AT_const_value {{.*}}"unable to open object file: [[MSG]]"
-CHECK:    NULL
-CHECK:  Compile Unit:
-CHECK:  DW_TAG_compile_unit [1] *
-CHECK:    DW_AT_producer {{.*}}"dsymutil
-CHECK:    DW_AT_name {{.*}}"/Inputs/basic3.macho.x86_64.o"
-CHECK:    DW_TAG_constant [2]
-CHECK:      DW_AT_name {{.*}}"dsymutil_warning"
-CHECK:      DW_AT_artificial [DW_FORM_flag]	(0x01)
-CHECK:      DW_AT_const_value {{.*}}"unable to open object file: [[MSG]]"
-CHECK:    NULL
diff --git a/llvm/test/tools/dsymutil/cmdline.test b/llvm/test/tools/dsymutil/cmdline.test
index dc716cf25b21fc2..2317852f3c489e2 100644
--- a/llvm/test/tools/dsymutil/cmdline.test
+++ b/llvm/test/tools/dsymutil/cmdline.test
@@ -21,7 +21,6 @@ CHECK: -object-prefix-map <prefix=remapped>
 CHECK: -oso-prepend-path <path>
 CHECK: -out <filename>
 CHECK: {{-o <filename>}}
-CHECK: -papertrail
 CHECK: -remarks-drop-without-debug
 CHECK: -remarks-output-format <format>
 CHECK: -remarks-prepend-path <path>
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index d1c239e994f61ee..9057a2d64092b1b 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -254,7 +254,6 @@ DwarfLinkerForBinary::loadObject(const DebugMapObject &Obj,
               });
             }),
         std::make_unique<AddressesMap>(*this, *ErrorOrObj, Obj),
-        Obj.empty() ? Obj.getWarnings() : EmptyWarnings,
         [&](StringRef FileName) { BinHolder.eraseObjectEntry(FileName); });
 
     Error E = RL.link(*ErrorOrObj);
@@ -791,8 +790,7 @@ bool DwarfLinkerForBinary::linkImpl(
                                    OnCUDieLoaded);
     } else {
       ObjectsForLinking.push_back(std::make_unique<OutDwarfFile>(
-          Obj->getObjectFilename(), nullptr, nullptr,
-          Obj->empty() ? Obj->getWarnings() : EmptyWarnings));
+          Obj->getObjectFilename(), nullptr, nullptr));
       GeneralLinker->addObjectFile(*ObjectsForLinking.back());
     }
   }
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index d3bda338a9b3230..d9bf2301e21e55f 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -28,11 +28,9 @@ class MachODebugMapParser {
 public:
   MachODebugMapParser(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
                       StringRef BinaryPath, ArrayRef<std::string> Archs,
-                      StringRef PathPrefix = "",
-                      bool PaperTrailWarnings = false, bool Verbose = false)
+                      StringRef PathPrefix = "", bool Verbose = false)
       : BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()),
-        PathPrefix(std::string(PathPrefix)),
-        PaperTrailWarnings(PaperTrailWarnings), BinHolder(VFS, Verbose),
+        PathPrefix(std::string(PathPrefix)), BinHolder(VFS, Verbose),
         CurrentDebugMapObject(nullptr), SkipDebugMapObject(false) {}
 
   /// Parses and returns the DebugMaps of the input binary. The binary contains
@@ -50,7 +48,6 @@ class MachODebugMapParser {
   std::string BinaryPath;
   SmallVector<StringRef, 1> Archs;
   std::string PathPrefix;
-  bool PaperTrailWarnings;
 
   /// Owns the MemoryBuffer for the main binary.
   BinaryHolder BinHolder;
@@ -137,13 +134,6 @@ class MachODebugMapParser {
                          << MachOUtils::getArchName(
                                 Result->getTriple().getArchName())
                          << ") " << File << " " << Msg << "\n";
-
-    if (PaperTrailWarnings) {
-      if (!File.empty())
-        Result->addDebugMapObject(File, sys::TimePoint<std::chrono::seconds>());
-      if (Result->end() != Result->begin())
-        (*--Result->end())->addWarning(Msg.str());
-    }
   }
 };
 
@@ -704,13 +694,11 @@ namespace dsymutil {
 llvm::ErrorOr<std::vector<std::unique_ptr<DebugMap>>>
 parseDebugMap(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
               StringRef InputFile, ArrayRef<std::string> Archs,
-              StringRef PrependPath, bool PaperTrailWarnings, bool Verbose,
-              bool InputIsYAML) {
+              StringRef PrependPath, bool Verbose, bool InputIsYAML) {
   if (InputIsYAML)
     return DebugMap::parseYAMLDebugMap(InputFile, PrependPath, Verbose);
 
-  MachODebugMapParser Parser(VFS, InputFile, Archs, PrependPath,
-                             PaperTrailWarnings, Verbose);
+  MachODebugMapParser Parser(VFS, InputFile, Archs, PrependPath, Verbose);
   return Parser.parse();
 }
 
diff --git a/llvm/tools/dsymutil/Options.td b/llvm/tools/dsymutil/Options.td
index 9b0b31b4b0e1d87..79f04fdfb036055 100644
--- a/llvm/tools/dsymutil/Options.td
+++ b/llvm/tools/dsymutil/Options.td
@@ -69,10 +69,6 @@ def yaml_input: Flag<["-", "--"], "y">,
   HelpText<"Treat the input file is a YAML debug map rather than a binary.">,
   Group<grp_general>;
 
-def papertrail: F<"papertrail">,
-  HelpText<"Embed warnings in the linked DWARF debug info.">,
-  Group<grp_general>;
-
 def assembly: Flag<["-", "--"], "S">,
   HelpText<"Output textual assembly instead of a binary dSYM companion file.">,
   Group<grp_general>;
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 49a3541e9ae78f1..104895b1a90bdaa 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -107,7 +107,6 @@ struct DsymutilOptions {
   bool DumpStab = false;
   bool Flat = false;
   bool InputIsYAMLDebugMap = false;
-  bool PaperTrailWarnings = false;
   bool ForceKeepFunctionForStatic = false;
   std::string SymbolMap;
   std::string OutputFile;
@@ -198,11 +197,6 @@ static Error verifyOptions(const DsymutilOptions &Options) {
         "cannot use -o with multiple inputs in flat mode.",
         errc::invalid_argument);
 
-  if (Options.PaperTrailWarnings && Options.InputIsYAMLDebugMap)
-    return make_error<StringError>(
-        "paper trail warnings are not supported for YAML input.",
-        errc::invalid_argument);
-
   if (!Options.ReproducerPath.empty() &&
       Options.ReproMode != ReproducerMode::Use)
     return make_error<StringError>(
@@ -304,7 +298,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
   Options.DumpStab = Args.hasArg(OPT_symtab);
   Options.Flat = Args.hasArg(OPT_flat);
   Options.InputIsYAMLDebugMap = Args.hasArg(OPT_yaml_input);
-  Options.PaperTrailWarnings = Args.hasArg(OPT_papertrail);
 
   if (Expected<DWARFVerify> Verify = getVerifyKind(Args)) {
     Options.Verify = *Verify;
@@ -390,9 +383,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
   if (Options.DumpDebugMap || Options.LinkOpts.Verbose)
     Options.LinkOpts.Threads = 1;
 
-  if (getenv("RC_DEBUG_OPTIONS"))
-    Options.PaperTrailWarnings = true;
-
   if (opt::Arg *RemarksPrependPath = Args.getLastArg(OPT_remarks_prepend_path))
     Options.LinkOpts.RemarksPrependPath = RemarksPrependPath->getValue();
 
@@ -687,8 +677,8 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
 
     auto DebugMapPtrsOrErr =
         parseDebugMap(Options.LinkOpts.VFS, InputFile, Options.Archs,
-                      Options.LinkOpts.PrependPath, Options.PaperTrailWarnings,
-                      Options.LinkOpts.Verbose, Options.InputIsYAMLDebugMap);
+                      Options.LinkOpts.PrependPath, Options.LinkOpts.Verbose,
+                      Options.InputIsYAMLDebugMap);
 
     if (auto EC = DebugMapPtrsOrErr.getError()) {
       WithColor::error() << "cannot parse the debug map for '" << InputFile
diff --git a/llvm/tools/dsymutil/dsymutil.h b/llvm/tools/dsymutil/dsymutil.h
index 60f8e3a07ff70f9..ddecd8a76c7fc96 100644
--- a/llvm/tools/dsymutil/dsymutil.h
+++ b/llvm/tools/dsymutil/dsymutil.h
@@ -35,8 +35,7 @@ namespace dsymutil {
 ErrorOr<std::vector<std::unique_ptr<DebugMap>>>
 parseDebugMap(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
               StringRef InputFile, ArrayRef<std::string> Archs,
-              StringRef PrependPath, bool PaperTrailWarnings, bool Verbose,
-              bool InputIsYAML);
+              StringRef PrependPath, bool Verbose, bool InputIsYAML);
 
 /// Dump the symbol table.
 bool dumpStab(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
diff --git a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
index fbbead16a03709b..f52e9092f5f75ba 100644
--- a/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
+++ b/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
@@ -335,7 +335,6 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options,
   DebugInfoLinker->setUpdateIndexTablesOnly(!Options.DoGarbageCollection);
 
   std::vector<std::unique_ptr<OutDwarfFile>> ObjectsForLinking(1);
-  std::vector<std::string> EmptyWarnings;
 
   // Add object files to the DWARFLinker.
   std::unique_ptr<DWARFContext> Context = DWARFContext::create(
@@ -354,9 +353,8 @@ Error linkDebugInfoImpl(object::ObjectFile &File, const Options &Options,
       std::make_unique<ObjFileAddressMap<AddressMapBase>>(*Context, Options,
                                                           File));
 
-  ObjectsForLinking[0] =
-      std::make_unique<OutDwarfFile>(File.getFileName(), std::move(Context),
-                                     std::move(AddressesMap), EmptyWarnings);
+  ObjectsForLinking[0] = std::make_unique<OutDwarfFile>(
+      File.getFileName(), std::move(Context), std::move(AddressesMap));
 
   uint16_t MaxDWARFVersion = 0;
   std::function<void(const DWARFUnit &Unit)> OnCUDieLoaded =



More information about the llvm-commits mailing list