From 99744346e431909eb921659cdc2cdf5e7de6bfa9 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 10 Apr 2014 21:53:47 +0000 Subject: [PATCH] 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. llvm-svn: 205989 --- include/llvm/MC/MCAssembler.h | 23 ++--------------- lib/MC/MCAssembler.cpp | 47 ----------------------------------- lib/MC/MCContext.cpp | 5 ---- lib/MC/MCObjectStreamer.cpp | 7 +----- test/MC/ELF/compression.s | 2 ++ 5 files changed, 5 insertions(+), 79 deletions(-) diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 34b760c46ee..424e5358e29 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -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 MCEncodedFragmentWithFixups { /// Fixups - The list of fixups in this fragment. SmallVector 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 CompressedContents; -public: - MCCompressedFragment(MCSectionData *SD = nullptr) - : MCDataFragment(FT_Compressed, SD) {} - const SmallVectorImpl &getCompressedContents() const; - using MCDataFragment::getContents; - SmallVectorImpl &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 diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index ddb543715c7..13336b91cb3 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -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::~MCEncodedFragmentWithFixups() { /* *** */ -const SmallVectorImpl &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(&Size), - reinterpret_cast(&Size + 1), - CompressedContents.begin() + Magic.size()); - } - return CompressedContents; -} - -SmallVectorImpl &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::computeFragmentSize(const MCAsmLayout &Layout, case MCFragment::FT_Relaxable: case MCFragment::FT_CompactEncodedInst: return cast(F).getContents().size(); - case MCFragment::FT_Compressed: - return cast(F).getCompressedContents().size(); case MCFragment::FT_Fill: return cast(F).getSize(); @@ -657,11 +619,6 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout, break; } - case MCFragment::FT_Compressed: - ++stats::EmittedDataFragments; - OW->WriteBytes(cast(F).getCompressedContents()); - break; - case MCFragment::FT_Data: ++stats::EmittedDataFragments; writeFragmentContents(F, OW); @@ -738,7 +695,6 @@ void MCAssembler::writeSectionData(const MCSectionData *SD, 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(this); OS << "\n "; diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 73ffdc0a4bd..9dfd6367ed7 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -258,11 +258,6 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags, 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 Entry = Map.insert( std::make_pair(SectionGroupPair(Section, Group), (MCSectionELF *)0)); diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 4451264cff6..2ae70f44b34 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -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::getOrCreateDataFragment() const { // 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(&getCurrentSectionData()->getSection()); - if (Sec && Sec->getSectionName().startswith(".zdebug_")) - F = new MCCompressedFragment(); - else - F = new MCDataFragment(); + F = new MCDataFragment(); insert(F); } return F; diff --git a/test/MC/ELF/compression.s b/test/MC/ELF/compression.s index 305a84e1bab..4e559059425 100644 --- a/test/MC/ELF/compression.s +++ b/test/MC/ELF/compression.s @@ -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: