Open MaskRay opened 6 months ago
@llvm/issue-subscribers-lld-elf
Author: Fangrui Song (MaskRay)
@compnerd @dwblaikie @jh7370 @PiJoules @petrhosek
Could we not add the none
type to llvm::compression::Format
and just have a single enumeration? We have too many cases of duplicates, let's try to avoid them if possible.
I was going to suggest that llvm::DebugCompressionType
was 1:1 with the SHF_COMPRESSED kinds, but it seems that isn't the case - well, at least it isn't /depended/ upon. eg: https://github.com/llvm/llvm-project/blob/3a106e5b2cd9f4073b2961b991ebaeee96786309/llvm/lib/Object/Decompressor.cpp#L42-L51
So, if it's not 1:1, so long as we have an enum that is at least as descriptive as the ELF compression kinds we support (if someone added an ELF compression kind we wouldn't/didn't support for some time - a switch like the one above could bail out, it wouldn't need to translate it into this underlying enum/representation) - there doesn't seem to be a great need to have more than one enum?
Could we not add the
none
type tollvm::compression::Format
and just have a single enumeration? We have too many cases of duplicates, let's try to avoid them if possible.
+1 to this (or something equivalent): we have two distinct enums in Compression.h
that do the same thing, except for the "none" value. I can't see any reason why we don't just have a single one: any code paths that use the Format
enum that don't want to support a none
value can just have an assert
/llvm_unreachable
added as appropriate.
llvm::DebugCompressionType
was added to support ELF compression, used by--compress-debug-sections
in assembler/linker/llvm-objcopy/etc. The type name made lots of sense in the past when the use cases were specific to.debug_*
sections. The name now makes less sense asllvm-readelf -z -x
,ld.lld --compress-sections
(andllvm-objcopy --compress-sections
) can (de)compress arbitrary sections.We should probably rename
llvm::DebugCompressionType
. There are a few choices:ELFCompressionType
: Since the current use cases are specific to ELF.CompressionType
: we haveDebugCompressionType CompressionType
variable names. We need to avoid identical type/variable names.We also have
llvm::compression::Format
, which can be used by other object file formats if they ever want to support compression.llvm::compression::Format
does not have a "no-compression" value whilellvm::DebugCompressionType
hasNone
.