I’m trying to understand how .llvmbc and .llvmcmd fit into an end-to-end story. From the RFC, and reading through the implementation, I’m piecing together that the goal was to enable capturing IR right after clang and before passing it to LLVM’s optimization passes, as well as the command line options needed for later compiling that IR to the same native object it was compiled to originally (with the same compiler).
Here’s what I don’t understand: say you have a.o and b.o compiled with -fembed-bitcode=all. They are linked into a binary called my_binary. How do you re-create the corresponding IR for modules a and b (let’s call them a.bc and b.bc), and their corresponding command lines? From what I can tell, the linker just concatenates the IR for a and b in my_binary’s .llvmbc, and the same for the command line in .llvmcmd. Is there a separator maybe I missed? For .llvmcmd, I could see how maybe -cc1 could be that separator, what about the .llvmbc part? The magic number?