<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54359>54359</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-stress-regalloc triggers assertion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
regalloc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
RKSimon,
uweigand,
topperc
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JonPsson
</td>
</tr>
</table>
<pre>
[testcase.tar.gz](https://github.com/llvm/llvm-project/files/8237996/testcase.tar.gz)
llc -O3 -addr-sink-using-gep=false -stress-regalloc=8 -misched=shuffle -o out.s ./tc_regscav.ll
LLVM ERROR: Error while trying to spill R11D from class ADDR64Bit: Cannot scavenge register without an emergency spill slot!
-stress-regalloc=8 limits the number of registers in each register class to 8:
< AllocationOrder(GR64Bit) = [ $r0d $r1d $r2d $r3d $r4d $r5d $r14d $r13d $r12d $r11d $r10d $r9d $r8d $r7d $r6d ]
---
> AllocationOrder(GR64Bit) = [ $r0d $r1d $r2d $r3d $r4d $r5d $r14d $r13d ]
This is changed in RegisterClassInfo.cpp: 'RCI.NumRegs = StressRA'.
This test case is apparently needing register scavenging, and in RegScavenger::scavengeRegisterBackwards() I see that 'AllocationOrder = RC.getRawAllocationOrder(MF)' is used, which includes the full register class, which is a little weird and makes me wonder if -stress-regalloc is broken (it was added 10 years ago by Jakob Stoklund Olesen).
It picks $r11 and then for some reason runs into the assertion above.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VMGSozYQ_Rp86YICYRtz4OCxZ1Oz2c2kmK1cU0ISoFhIlCTG5Xx9WoBndndyySFVLrWFWt2vX79WY_ititJzlB6j3YMXzjPqROKpTbq_o905Iofe-9FF-TEin_DXSd9PTcLMgBulXu8mHq35SzCP21Yq4dAeSF6U5R7__RyXlGvKeVWKAcTPOcSUcxs7qS_xhGsXd2KM8nNLlRMQO2-Fc7EVHVXKMDw4QDxIx3rBceP6qW0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