<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61215>61215</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[CodeGen] TCO should always use a scratch register in the given calling convention
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
namazso
</td>
</tr>
</table>
<pre>
Repro: https://godbolt.org/z/3ccbE69xs
The requested tailcall is clearly possible under the given conditions, by simply storing the target in r11. It instead uses rax, then immediately clobbers it before actually doing the `jmp rax`.
Related: https://github.com/llvm/llvm-project/issues/52734 which should probably be changed to only be about cross-cc tailcalls.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycks1unTwQhq_GbEZBxvycnAWLfMlH1VWlKDcwtueAI2NTjzkJufoKotNm0VU3YFmekZ73eZHZjYGoF-1_on0qcM1TTH3AGT84FjrarX-mJUVRP8CU88KifhBqEGoYo9XR5zKmUajhQ6ihNkb_353fWcgnIR8-vy8TQaKfK3EmCxmdN-g9OAbjCZPfYInMTnuCNVhKkCeC0V0pgInBuuxiYKEeQW_Abl78BpxjcmE8XmZMI2VwAVJVlfB9P3ImtLAyMSR832fzRAHcPJN1mMlvYHzUmhKDy6DpEhMBmryi9xvYeFsuOvk6L8eSTpZfqZ7JYyb7l1RcnlZdmjgLNXh_vf3ulhRfyWShBse8Egs1tOpUN_A2OTMBT3H1FpYUNWq_gSYwE4ZxzyxCDJ9XqOOawaTIfGfM7zS5LGxf23N9xoL6qjvdV5VU56qYelJEtlL3mow8naRp6sq2KOkiO1RtowvXK6lqWcuuqpumrcrmgu2FLurUtkrL7iIaSTM6X-4Yu-3iAOi7SlVt4VGT51t9Un-w6nVk0UjvOPOfseyyP4r2GC19oyDaJ3h5_HFDR_-GG-_aAIFNwmwmSDQ6zpR2wV-Kgd7vjkwMVwp7Q4o1-f7fTRwsvwIAAP__M0MEeg">