<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140904>140904</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LoongArch] Assertion failure 'MachineOperand::getIndex() const: (isFI() || isCPI() || isTargetIndex() || isJTI()) && "Wrong MachineOperand accessor"' failed.'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:crash,
backend:loongarch
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
heiher
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
heiher
</td>
</tr>
</table>
<pre>
While building the Linux kernel for the LoongArch using Clang, the following assertion failure occurs:
```
llvm/include/llvm/CodeGen/MachineOperand.h:572: int llvm::MachineOperand::getIndex() const: Assertion (isFI() || isCPI() || isTargetIndex() || isJT
I()) && "Wrong MachineOperand accessor"' failed.
```
This happens when compiling the file `drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c`.
Clang invocation:
```sh
clang -Wp,-MMD,drivers/net/wireless/realtek/rtlwifi/rtl8821ae/.phy.o.d -nostdinc -I./arch/loongarch/include -I./arch/loongarch/include/generated -I./include -I./include -I./arch/loongarch/include/uapi -I./arch/loongarch/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ --target=loongarch64-linux-gnusf -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DVMLINUX_LOAD_ADDRESS=0x9000000000200000 -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-relax -mannotate-tablejump -mabi=lp64s -mcmodel=normal -pipe -msoft-float -fno-builtin-memcpy -fno-builtin-memmove -fno-builtin-memset -fno-asynchronous-unwind-tables -mstrict-align -isystem /tmp/rel/lib/clang/21/include -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -ftrivial-auto-var-init=zero -fpatchable-function-entry=2 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-gnu -Wno-format-overflow-non-kprintf -Wno-format-truncation-non-kprintf -Wno-default-const-init-unsafe -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow -Wno-override-init -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-enum-compare-conditional -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-enum-enum-conversion -Wno-sign-compare -Wno-unused-parameter -g -DMODULE -fno-direct-access-external-data -DKBUILD_BASENAME=\"phy\" -DKBUILD_MODNAME=\"rtl8821ae\" -D__KBUILD_MODNAME=kmod_rtl8821ae -c -o drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.o drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
```
Clang version:
```
clang version 21.0.0git (https://github.com/llvm/llvm-project 1a08aa2680da76258a2f8252ab63d05e5638b9da)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /tmp/rel/bin
Build config: +assertions
```
Linux kernel version:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tag/?h=v6.15-rc7
Kernel config:
`arch/loongarch/configs/loongson3_defconfig`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysV11z4yoS_TXkhcIlI3_lIQ-KFd_N3nxMzWQ2u08uDC2JGwQqQE5yf_1WIzmxk6mdmpq9lbojN6ehORy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