Currently a bitcode file has no terminator. If several bitcode files are
concatenated, there is no suitable tool splitting them. For example:
clang -fembed-bitcode=all -c a.c b.c ld a.o b.o objcopy --dump-section=.llvmbc=a.bc a.out /dev/null llvm-dis a.bc # LLVM ERROR: Invalid encoding
This is because llvm-dis does not terminate after reaching the end of the first
stream, and decodes the start of the second bitcode file as the continuation
instead, and fail.
This patch introduces an optional BITCODE_SIZE_BLOCK_ID block to encode the size
of the stream. The block can be placed anywhere in the stream. For a streaming
writer, BITCODE_SIZE_BLOCK_ID can be placed at the end as a terminator. If
random access is supported, BITCODE_SIZE_BLOCK_ID can be placed earlier to allow
fast filtering (by parsing some metadata records like MODULE_CODE_SOURCE_FILENAME).
llvm-dis is taught to handle concatenated streams.
clang-tidy: warning: invalid case style for function 'GetBufferOffset' [readability-identifier-naming]
not useful