<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64452>64452</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[x86_64/GlobalISel] Crash on `lshr` due to error "Register class not set, wrong accessor" when targeting some CPUs
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HazyFish
</td>
</tr>
</table>
<pre>
## Description
When targeting Intel `sapphirerapids` / `icelake-server`, or AMD `znver4` CPU with Global ISel, IR instruction `lshr` crashes the `x86_64` backend with Assertion Error `isa<const TargetRegisterClass *>(VRegInfo[Reg.id()].first) && "Register class not set, wrong accessor"` during `X86 Domain Reassignment Pass`.
The problem cannot be reproduced when targeting `raptorlake`, `alderlake`, `znver3` CPUs, when CPU is not specified, or when Global ISel is not used,
## Minimal Reproduction
https://godbolt.org/z/xY9voTn4z
### Code
```ll
define void @f(i64 %0) {
%unused = lshr i64 %0, 7
ret void
}
```
### Stack Trace
```console
llc: /root/llvm-project/llvm/include/llvm/CodeGen/MachineRegisterInfo.h:663: const llvm::TargetRegisterClass* llvm::MachineRegisterInfo::getRegClass(llvm::Register) const: Assertion `isa<const TargetRegisterClass *>(VRegInfo[Reg.id()].first) && "Register class not set, wrong accessor"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mcpu=sapphirerapids --global-isel <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'X86 Domain Reassignment Pass' on function '@f'
#0 0x0000000003398418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3398418)
#1 0x0000000003395d0c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f6293365420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f6292e2800b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f6292e07859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f6292e07729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f6292e18fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x0000000001ae99f6 (anonymous namespace)::X86DomainReassignment::runOnMachineFunction(llvm::MachineFunction&) (.part.0) X86DomainReassignment.cpp:0:0
#8 0x0000000002680049 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#9 0x0000000002bf8bb9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8bb9)
#10 0x0000000002bf8df1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf8df1)
#11 0x0000000002bf9612 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf9612)
#12 0x000000000075e092 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#13 0x000000000069a7e6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x69a7e6)
#14 0x00007f6292e09083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#15 0x0000000000754a4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x754a4e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWF1vIysS_TX4BdnC0O6PBz947HhupIk2SmZn7z5FNF3dZoeGFtCJM79-Bd1O3B7rKrM7Wm3kRAkUpw5VpwoId042GmCNVp_QajfjvT8Yu_6D_3jdS3eYlaZ6XSPKEGV4B05Y2XlpNCI7RDbDz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