JumpTableEntryInfo is initialized during the instruction selection phase via AArch64FunctionInfo::setJumpTableEntryInfo. However, if we try to run a mir file containing jump tables with llc, then it will crash since no elements in JumpTableEntryInfo. With this patch, we don't need to look up JumpTableEntryInfo for element size and a local label will be created if JumpTableEntryInfo is not initialized.
e.g.
asm.ll (https://reviews.llvm.org/F26307823)
llc -mtriple=aarch64 -stop-after=unpack-mi-bundles asm.ll -o asm.mir
llc -mtriple=aarch64 -start-after=unpack-mi-bundles asm.mir -o asm.s
llc: /root/sinan/llvm-project/llvm/include/llvm/ADT/SmallVector.h:298: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) const [with T = std::pair<unsigned int, llvm::MCSymbol*>; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::const_reference = const std::pair<unsigned int, llvm::MCSymbol*>&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: ./../../../../llvm-dev-install/bin/llc -mtriple=aarch64 -start-after=unpack-mi-bundles asm.mir -o asm.s 1. Running pass 'Function Pass Manager' on module 'asm.mir'. 2. Running pass 'AArch64 Assembly Printer' on function '@sum' #0 0x00000000019fecfc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./../../../../llvm-dev-install/bin/llc+0x19fecfc) #1 0x00000000019fd420 llvm::sys::RunSignalHandlers() (./../../../../llvm-dev-install/bin/llc+0x19fd420) #2 0x00000000019fd5e4 SignalHandler(int) Signals.cpp:0:0 #3 0x0000ffff84f377b0 (linux-vdso.so.1+0x7b0) #4 0x0000ffff849e9e98 raise (/lib64/libc.so.6+0x37e98) #5 0x0000ffff849d650c abort (/lib64/libc.so.6+0x2450c) #6 0x0000ffff849e31e8 __assert_fail_base (/lib64/libc.so.6+0x311e8) #7 0x0000ffff849e324c .annobin___GI___assert_fail.end assert.c:0:0
This change has no impact on the normal routine and enables writing mir test with a jump table.
I don't think you need a dedicated testcase for this, if you're planning to use this functionality in the near future.