<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88647>88647</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM ERROR: Error while trying to spill X19 from class GPR64: Cannot scavenge register without an emergency spill slot!
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DigOrDog
</td>
</tr>
</table>
<pre>
# Description
The following code crashes aarch64 backend with "Error while trying to spill X19 from class GPR64: Cannot scavenge register without an emergency spill slot!"
# Minimal Reproduction
https://godbolt.org/z/7MzzbfoPe
## code
```
define i1 @f(i16 %0, i64 %1, i32 %2, ptr %G.1, ptr %A, ptr %RP, i8 %L, i32 %L2, i1 %C1, i1 %C4, i1 %C) {
BB:
%A1 = alloca i1, i32 2, align 1
%L5 = load i1, ptr null, align 1
%B6 = shl i1 false, %L5
%G2 = getelementptr i1, ptr %A, i32 %2
%B1 = and i64 %1, 0
%G7 = getelementptr i64, ptr %A1, i64 42
store ptr %G.1, ptr %G7, align 8
%B2 = or i64 0, %1
%B4 = and i8 %L, 0
store i8 poison, ptr %RP, align 1
store i64 %B1, ptr null, align 4
store i64 %B2, ptr null, align 4
store i1 %C1, ptr %G2, align 1
store i1 %C4, ptr null, align 1
store i8 %B4, ptr null, align 1
store i64 0, ptr %G.1, align 4
store i1 %B6, ptr null, align 1
store i16 %0, ptr null, align 2
store i32 %L2, ptr null, align 4
ret i1 %C
}
```
## Stack Trace
```
LLVM ERROR: Error while trying to spill X19 from class GPR64: Cannot scavenge register without an emergency spill slot!
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=aarch64 -O=0 <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@f'
#0 0x0000000003947fe8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3947fe8)
#1 0x000000000394573c SignalHandler(int) Signals.cpp:0:0
#2 0x00007fed73642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007fed736969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007fed73642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007fed736287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000000000071f3bd (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x71f3bd)
#7 0x0000000002b757ce llvm::RegScavenger::spill(llvm::Register, llvm::TargetRegisterClass const&, int, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2b757ce)
#8 0x0000000002b760a2 llvm::RegScavenger::scavengeRegisterBackwards(llvm::TargetRegisterClass const&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, bool, int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2b760a2)
#9 0x0000000002b77150 scavengeFrameVirtualRegsInBlock(llvm::MachineRegisterInfo&, llvm::RegScavenger&, llvm::MachineBasicBlock&) RegisterScavenging.cpp:0:0
#10 0x0000000002b775e3 llvm::scavengeFrameVirtualRegs(llvm::MachineFunction&, llvm::RegScavenger&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2b775e3)
#11 0x0000000002add8a7 (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) PrologEpilogInserter.cpp:0:0
#12 0x000000000295c471 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#13 0x0000000002f1b493 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f1b493)
#14 0x0000000002f1b6d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f1b6d1)
#15 0x0000000002f1bf35 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f1bf35)
#16 0x0000000000827f6c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#17 0x0000000000726a36 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x726a36)
#18 0x00007fed73629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#19 0x00007fed73629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#20 0x000000000081ea8e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x81ea8e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWF1v2zoS_TX0C2FDoj794Ic4jrMBEjRwimLfApoaydxQpEBSN0l__YKUbEuO2ya7xr1F2tLK8MyZM8MZytQYXkmABUqWKFlNaGt3Si9WvPqmV6qabFXxvkAkwiswTPPGciVRsELB1fcd4FIJoV65rDBTBWCmqdmBwZRqtktjvKXsBWSBX7ndYUTIjdZK49cdF4Ctfnf7rMKm4ULgf4dzXGpVYyaoMfj2cZPGKLrC11RKZbFh9C-QFWANFTcWtAdVrcVUYqhBVyDZe49lhLKIhIiQjmr_L4nwA5e8pgJvoNGqaNkxnJ21jUHRFSJrRNaVKrZK2JnSFSLrn4iss4efP7eleoQTSIfqgu8fpEH_4z8WUHIJmIcYxUGJSM7DFCOSBIhcY57Gbh36dUTcmrh1Y7Vb387CwaerwXrz6Lfkbn0_2H3vtztnJLkOB-t4sEZkjlG27Pgtly5iv8TeS4hRtMJUCMUo5gdqHpgKXkkcDszvE28uFC16Y8dQtkKct1-m3t7shGNTUmHAGXqkgdkt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