[llvm] r355505 - [llvm-objcopy] - Remove dead code. NFCI.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 06:12:18 PST 2019


Author: grimar
Date: Wed Mar  6 06:12:18 2019
New Revision: 355505

URL: http://llvm.org/viewvc/llvm-project?rev=355505&view=rev
Log:
[llvm-objcopy] - Remove dead code. NFCI.

DecompressedSection can only be created if --decompress-debug-sections is specified.
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/ELF/ELFObjcopy.cpp#L492

If it is specified when !zlib::isAvailable(), we error out early when parsing the options:
https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-objcopy/CopyConfig.cpp#L657

What means the code I am removing in this patch is dead.

Differential revision: https://reviews.llvm.org/D59017

Modified:
    llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp

Modified: llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp?rev=355505&r1=355504&r2=355505&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp (original)
+++ llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp Wed Mar  6 06:12:18 2019
@@ -182,13 +182,6 @@ getDecompressedSizeAndAlignment(ArrayRef
 
 template <class ELFT>
 void ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
-  uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
-
-  if (!zlib::isAvailable()) {
-    std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf);
-    return;
-  }
-
   const size_t DataOffset = isDataGnuCompressed(Sec.OriginalData)
                                 ? (ZlibGnuMagic.size() + sizeof(Sec.Size))
                                 : sizeof(Elf_Chdr_Impl<ELFT>);
@@ -202,6 +195,7 @@ void ELFSectionWriter<ELFT>::visit(const
                                  static_cast<size_t>(Sec.Size)))
     reportError(Sec.Name, std::move(E));
 
+  uint8_t *Buf = Out.getBufferStart() + Sec.Offset;
   std::copy(DecompressedContent.begin(), DecompressedContent.end(), Buf);
 }
 




More information about the llvm-commits mailing list