Context:
- In the ThinLTO minimized code [1], ThinLTOBitcodeWriter has a different format for GlobalVar [2] that's not yet supported by BitcodeReader yet. So add a flag to tell llvm-dis to parse thin-lto index only.
- From the iterative discussion and development of this patch, there isn't a clean, automatic way to choose a bitcode reader (that's as simple as adding a flag llvm-dis). An alternative option is to modify BitcodeReader to support the GlobalVar format, but that's going to be more involved change.
[1] e.g., bitcode generated by opt --thin-link-bitcode-file=<minimized-bitcode> or clang -Xclang -fthin-link-bitcode=<minimized-bitcode>
[2] https://github.com/llvm/llvm-project/blob/b6a93967d9c11e79802b5e75cec1584d6c8aa472/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4741
FYI looks like FUNCTION, ALIAS and IFUNC have the same issue. I'm not sure if there is a good common place to leave a comment about handling all of those?