llvm-obj dump can crash when it can't disassemble an instruction:
llvm-objdump: llvm/include/llvm/ADT/SmallVector.h:153: llvm::SmallVectorTemplateCommon::const_reference llvm::SmallVectorTemplateCommon<llvm::MCOperand, void>::operator[](llvm::SmallVectorTemplateCommon::size_type) const [T = llvm::MCOperand]: Assertion `idx < size()' failed.
This can happen when the source is compiled with:
clang -march=..+ext1+ext2
and disassembly is attempted with:
llvm-objdump -mattr=+ext1
I.e., it isn't given the same architecture extensions. I have tried adding a test case, by taking our proprietary disassembler and generate the assembly code for the offending assembly sequence, let llvm-mc assemble that, and then llvm-objdump disassemble it again:
llvm-mc -assemble ... | llvm-objdump -disassemble ..
but I just can't reproduce it in this way; llvm-mc or llvm-objdump is perhaps behaving slightly differently, perhaps there's some state somewhere. I have visually inspected the code though: first of all, it no longer crashes, and also it looks okay (and the test suite passes).
To be clear, does this test result in a crash without your fix?
It would be a good idea to add a comment to the top of this test to explain what is going on, why you use the switches you do, and why you use the content you do.