<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/147813>147813</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`musttail` generates redundant moves on 32-bit platforms
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
brandtbucher
</td>
</tr>
</table>
<pre>
For example, this code:
```cpp
int bar(int);
int
foo_tail(int x)
{
// Correct, compiles to a single jmp:
return bar(x);
}
int
foo_musttail(int x)
{
// Buggy, loads and re-spills all parameters:
__attribute__((musttail)) return bar(x);
}
```
Compiles to:
```s
_foo_tail:
jmp _bar
_foo_musttail:
movl 4(%esp), %eax
movl %eax, 4(%esp)
jmp _bar
```
[Compiler Explorer](https://godbolt.org/z/sYoMMjoxY)
Adding more parameters to the function (and tail call) increases the number of redundant loads/spills, too.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMU8uOozgU_RqzuUpkTAiwYJGkhl19QK2QwRdw5AeyTSY1Xz8yoStV6UW3hIQsH_u8fLn3cjSINcnPJH9L-BIm6-rOcSNCt_QTuqSz4rNurAO8cz0rJOwCYZIeeiuQZCdC1-9IH18_z4SepAnQcUdYKU0grCLZ-YGLS3oarG0Dl-qxD_eIoCdSRBAAAGENYQ1crHPYh8jYWz1LhR6CBQ5emlEhXPX8EBDPOAyLMxvr_clZvL0y68WHv2A_L-P4GbmV5cIDNwIc7vwslfLAlYKZO64xoPNPFW3LQ3CyWwK2LWElYeWTriKs-oPOXzE-NF-ern9P2hN6ar-S3BRc9QxtvHvFtj_sbhBtbwoOq7Yc_bzKukBc8PsTsK3Z5QX6SvJTMMnPm2YH_9xnZR06kr8RVk4hzGtOa7ijFZ1VYW_dSFjzH2GN_7Dv71d7_9jaoKeTENKMoK3Db1HHBxAmhGExfZDWAGFlrCY6hJ6rGDNI0zvkPgY3IZhFd-jADuBQLEZwEx6dRtq1zvVNW7tPRJ2JKqt4gnVa5IxW9HjMkqk-HNKq4kOfsy6n4ojlYRBDNpQFY0U1iC6RNaMspwWt0ipPKdvTomNpnvYCRSoqRHKgqLlUe6VuOvpOpPcL1umhKNMsUbxD5dc5ZMzgv7DuEsbiWLo6Htp1y-jJgSrpg39eE2RQWJMj_er5SGFEg44H9N8sa3tDD9ZAxnadDDArHgbrtE8Wp-qXfmSYlm7fW01YE6m232529rqOZLMKjBFuDm41-z8AAP__dlZSIw">