This adds support for embedding bitcode in a binary during LTO. The libLTO gains supports the -lto-embed-bitcode option which accepts off, all, bitcode, and marker. The semantics are the same as for clangs -fembed-bitcode. The option allows users of the LTO library to embed a bitcode section. For example, LLD can pass the option via ld.lld -mllvm=-lto-embed-bitcode=all.
This feature allows doing something comparable to clang -c -fembed-bitcode, but on the (LTO) linker level. Having bitcode alongside native code has many use-cases. To give an example, the MacOS linker can create a -bitcode_bundle section containing bitcode. Also, having this feature built into LLVM is an alternative to 3rd party tools such as wllvm or gllvm. As with these tools, this feature simplifies creating "whole-program" llvm bitcode files, but in contrast to wllvm/gllvm it does not rely on a specific llvm frontend/driver.
I originally proposed this feature as an addition to LLD. It turned out, however, that doing this purely on LLVM/LTO side is more general and might be useful to a broader audience.
The implementation is quite straight forward. The embedding logic moved from clang to llvm/lib/Bitcode and llvm/lib/LTO gained the -lto-embed-bitcode option. Most code just moved.