[llvm] r205989 - Revert debug info compression support.

David Blaikie dblaikie at gmail.com
Thu Apr 10 14:53:48 PDT 2014


Author: dblaikie
Date: Thu Apr 10 16:53:47 2014
New Revision: 205989

URL: http://llvm.org/viewvc/llvm-project?rev=205989&view=rev
Log:
Revert debug info compression support.

To support compression for debug_line and debug_frame a different
approach is required. To simplify review, revert the old implementation
and XFAIL the test case. New implementation to follow shortly.

Reverts r205059 and r204958.

Modified:
    llvm/trunk/include/llvm/MC/MCAssembler.h
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/lib/MC/MCContext.cpp
    llvm/trunk/lib/MC/MCObjectStreamer.cpp
    llvm/trunk/test/MC/ELF/compression.s

Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=205989&r1=205988&r2=205989&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu Apr 10 16:53:47 2014
@@ -52,7 +52,6 @@ public:
   enum FragmentType {
     FT_Align,
     FT_Data,
-    FT_Compressed,
     FT_CompactEncodedInst,
     FT_Fill,
     FT_Relaxable,
@@ -162,7 +161,6 @@ public:
         return false;
       case MCFragment::FT_Relaxable:
       case MCFragment::FT_CompactEncodedInst:
-      case MCFragment::FT_Compressed:
       case MCFragment::FT_Data:
         return true;
     }
@@ -197,8 +195,7 @@ public:
 
   static bool classof(const MCFragment *F) {
     MCFragment::FragmentType Kind = F->getKind();
-    return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data ||
-           Kind == MCFragment::FT_Compressed;
+    return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data;
   }
 };
 
@@ -217,11 +214,6 @@ class MCDataFragment : public MCEncodedF
 
   /// Fixups - The list of fixups in this fragment.
   SmallVector<MCFixup, 4> Fixups;
-protected:
-  MCDataFragment(MCFragment::FragmentType FType, MCSectionData *SD = 0)
-      : MCEncodedFragmentWithFixups(FType, SD), HasInstructions(false),
-        AlignToBundleEnd(false) {}
-
 public:
   MCDataFragment(MCSectionData *SD = 0)
     : MCEncodedFragmentWithFixups(FT_Data, SD),
@@ -255,21 +247,10 @@ public:
   const_fixup_iterator fixup_end() const override {return Fixups.end();}
 
   static bool classof(const MCFragment *F) {
-    return F->getKind() == MCFragment::FT_Data ||
-           F->getKind() == MCFragment::FT_Compressed;
+    return F->getKind() == MCFragment::FT_Data;
   }
 };
 
-class MCCompressedFragment: public MCDataFragment {
-  mutable SmallVector<char, 32> CompressedContents;
-public:
-  MCCompressedFragment(MCSectionData *SD = nullptr)
-      : MCDataFragment(FT_Compressed, SD) {}
-  const SmallVectorImpl<char> &getCompressedContents() const;
-  using MCDataFragment::getContents;
-  SmallVectorImpl<char> &getContents() override;
-};
-
 /// This is a compact (memory-size-wise) fragment for holding an encoded
 /// instruction (non-relaxable) that has no fixups registered. When applicable,
 /// it can be used instead of MCDataFragment and lead to lower memory

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=205989&r1=205988&r2=205989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Apr 10 16:53:47 2014
@@ -28,9 +28,6 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Compression.h"
-#include "llvm/Support/Host.h"
 
 using namespace llvm;
 
@@ -233,39 +230,6 @@ MCEncodedFragmentWithFixups::~MCEncodedF
 
 /* *** */
 
-const SmallVectorImpl<char> &MCCompressedFragment::getCompressedContents() const {
-  assert(getParent()->size() == 1 &&
-         "Only compress sections containing a single fragment");
-  if (CompressedContents.empty()) {
-    // FIXME: could be more efficient if we let zlib::compress append to a
-    // buffer rather than always from the start.
-    zlib::Status Success =
-        zlib::compress(StringRef(getContents().data(), getContents().size()),
-                       CompressedContents);
-    (void)Success;
-    assert(Success == zlib::StatusOK);
-    static const StringRef Magic = "ZLIB";
-    uint64_t Size = getContents().size();
-    if (sys::IsLittleEndianHost)
-      Size = sys::SwapByteOrder(Size);
-    CompressedContents.insert(CompressedContents.begin(),
-                              Magic.size() + sizeof(Size));
-    std::copy(Magic.begin(), Magic.end(), CompressedContents.begin());
-    std::copy(reinterpret_cast<char *>(&Size),
-              reinterpret_cast<char *>(&Size + 1),
-              CompressedContents.begin() + Magic.size());
-  }
-  return CompressedContents;
-}
-
-SmallVectorImpl<char> &MCCompressedFragment::getContents() {
-  assert(CompressedContents.empty() &&
-         "Fragment contents should not be altered after compression");
-  return MCDataFragment::getContents();
-}
-
-/* *** */
-
 MCSectionData::MCSectionData() : Section(0) {}
 
 MCSectionData::MCSectionData(const MCSection &_Section, MCAssembler *A)
@@ -467,8 +431,6 @@ uint64_t MCAssembler::computeFragmentSiz
   case MCFragment::FT_Relaxable:
   case MCFragment::FT_CompactEncodedInst:
     return cast<MCEncodedFragment>(F).getContents().size();
-  case MCFragment::FT_Compressed:
-    return cast<MCCompressedFragment>(F).getCompressedContents().size();
   case MCFragment::FT_Fill:
     return cast<MCFillFragment>(F).getSize();
 
@@ -657,11 +619,6 @@ static void writeFragment(const MCAssemb
     break;
   }
 
-  case MCFragment::FT_Compressed:
-    ++stats::EmittedDataFragments;
-    OW->WriteBytes(cast<MCCompressedFragment>(F).getCompressedContents());
-    break;
-
   case MCFragment::FT_Data: 
     ++stats::EmittedDataFragments;
     writeFragmentContents(F, OW);
@@ -738,7 +695,6 @@ void MCAssembler::writeSectionData(const
            ie = SD->end(); it != ie; ++it) {
       switch (it->getKind()) {
       default: llvm_unreachable("Invalid fragment in virtual section!");
-      case MCFragment::FT_Compressed:
       case MCFragment::FT_Data: {
         // Check that we aren't trying to write a non-zero contents (or fixups)
         // into a virtual section. This is to support clients which use standard
@@ -1070,8 +1026,6 @@ void MCFragment::dump() {
   switch (getKind()) {
   case MCFragment::FT_Align: OS << "MCAlignFragment"; break;
   case MCFragment::FT_Data:  OS << "MCDataFragment"; break;
-  case MCFragment::FT_Compressed:
-    OS << "MCCompressedFragment"; break;
   case MCFragment::FT_CompactEncodedInst:
     OS << "MCCompactEncodedInstFragment"; break;
   case MCFragment::FT_Fill:  OS << "MCFillFragment"; break;
@@ -1098,7 +1052,6 @@ void MCFragment::dump() {
        << " MaxBytesToEmit:" << AF->getMaxBytesToEmit() << ">";
     break;
   }
-  case MCFragment::FT_Compressed:
   case MCFragment::FT_Data:  {
     const MCDataFragment *DF = cast<MCDataFragment>(this);
     OS << "\n       ";

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=205989&r1=205988&r2=205989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Thu Apr 10 16:53:47 2014
@@ -258,11 +258,6 @@ getELFSection(StringRef Section, unsigne
     ELFUniquingMap = new ELFUniqueMapTy();
   ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
 
-  SmallString<32> ZDebugName;
-  if (MAI->compressDebugSections() && Section.startswith(".debug_") &&
-      Section != ".debug_frame" && Section != ".debug_line")
-    Section = (".z" + Section.drop_front(1)).toStringRef(ZDebugName);
-
   // Do the lookup, if we have a hit, return it.
   std::pair<ELFUniqueMapTy::iterator, bool> Entry = Map.insert(
       std::make_pair(SectionGroupPair(Section, Group), (MCSectionELF *)0));

Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=205989&r1=205988&r2=205989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Thu Apr 10 16:53:47 2014
@@ -20,7 +20,6 @@
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/MC/MCSectionELF.h"
 using namespace llvm;
 
 MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
@@ -64,11 +63,7 @@ MCDataFragment *MCObjectStreamer::getOrC
   // When bundling is enabled, we don't want to add data to a fragment that
   // already has instructions (see MCELFStreamer::EmitInstToData for details)
   if (!F || (Assembler->isBundlingEnabled() && F->hasInstructions())) {
-    const auto *Sec = dyn_cast<MCSectionELF>(&getCurrentSectionData()->getSection());
-    if (Sec && Sec->getSectionName().startswith(".zdebug_"))
-      F = new MCCompressedFragment();
-    else
-      F = new MCDataFragment();
+    F = new MCDataFragment();
     insert(F);
   }
   return F;

Modified: llvm/trunk/test/MC/ELF/compression.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/compression.s?rev=205989&r1=205988&r2=205989&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/compression.s (original)
+++ llvm/trunk/test/MC/ELF/compression.s Thu Apr 10 16:53:47 2014
@@ -1,5 +1,7 @@
 // RUN: llvm-mc -filetype=obj -compress-debug-sections -triple x86_64-pc-linux-gnu %s -o - | llvm-objdump -s - | FileCheck %s
 
+// XFAIL: *
+
 // REQUIRES: zlib
 
 // CHECK: Contents of section .debug_line:





More information about the llvm-commits mailing list