[all-commits] [llvm/llvm-project] a41977: [Support] Add llvm::compression::{getReasonIfUnsup...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Sep 8 00:59:12 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a41977dd0f4fd7aaad5ec380d50782296a690b47
      https://github.com/llvm/llvm-project/commit/a41977dd0f4fd7aaad5ec380d50782296a690b47
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M llvm/include/llvm/MC/MCTargetOptions.h
    M llvm/include/llvm/Support/Compression.h
    M llvm/lib/Support/Compression.cpp
    M llvm/unittests/Support/CompressionTest.cpp

  Log Message:
  -----------
  [Support] Add llvm::compression::{getReasonIfUnsupported,compress,decompress}

as high-level API on top of `llvm::compression::{zlib,zstd}::*`:

* getReasonIfUnsupported: return nullptr if the specified format is
  supported, or (if unsupported) a string like `LLVM was not built with LLVM_ENABLE_ZLIB ...`
* compress: dispatch to zlib::uncompress or zstd::uncompress
* decompress: dispatch to zlib::uncompress or zstd::uncompress

Move `llvm::DebugCompressionType` from MC to Support to avoid Support->MC cyclic
dependency. There are 40+ uses in llvm-project.

Add another enum class `llvm::compression::Format` to represent supported
compression formats, which may be a superset of ELF compression formats.

See D130458 (llvm-objcopy --{,de}compress-debug-sections for zstd) for a use
case.

Link: https://discourse.llvm.org/t/rfc-zstandard-as-a-second-compression-method-to-llvm/63399
("[RFC] Zstandard as a second compression method to LLVM")

---

Note: this patch alone will cause -Wswitch to llvm/lib/ObjCopy/ELF/ELFObject.cpp

Reviewed By: ckissane, dblaikie

Differential Revision: https://reviews.llvm.org/D130506




More information about the All-commits mailing list