There are two ways .llvmbc can be produced:
- clang -c -fembed-bitcode=all (which also produces .llvmcmd)
- LTO backend: ld.lld -mllvm -lto-embed-bitcode or -plugin-opt=-lto-embed-bitcode
.llvmbc and .llvmcmd have the SHF_ALLOC flag, so they can be dropped by
--gc-sections.
This patch sets SectionKind::Metadata to drop the SHF_ALLOC flag. This
is conceptually correct: the two sections are not part of the process
image, so SHF_ALLOC is not appropriate.
test/LTO/X86/embed-bitcode.ll: changed llvm-objcopy -O binary --only-section to
llvm-objcopy --dump-section. -O binary does not dump non-SHF_ALLOC sections.