<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/67249>67249</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [X86] Musttail calls involving unions with long double members are miscompiled at -O2
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alexshpilkin
      </td>
    </tr>
</table>

<pre>
    On x86_64-linux-gnu, both Clang 14 (on my machine) and [Clang trunk (on Godbolt)](https://godbolt.org/z/37qcEWEPE) set to `-O2` compile `bar` in

```c
union u {
    long double ldbl;
};

void foo(union u acc);

void bar(union u acc) {
 __attribute__((musttail)) return foo(acc);
}
```

to

```asm
movaps  xmm0, xmmword ptr [rsp + 8]
movaps  xmmword ptr [rsp], xmm0
movaps  xmmword ptr [rsp + 8], xmm0
jmp     foo@PLT                         # TAILCALL
```

which is not only nonsensical but is a guaranteed segmentation violation, as it involves two consecutive MOVAPSes to addresses 8 bytes apart, when MOVAPS requires 16-byte alignment.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE1v4zYQ_TXUZeCAHksyddDBieOiQBYJ0EXbm0GJtMRdfmj5YTv99QVlFdk1tq1hUNTM45sZPs3wENRgpWxJ9UiqfcFTHJ1vuZbXME5Kf1W26Jx4b18tXFl9rMuVVjZdV4NNBJ-gc3GEJ83tAOsSCDJnwbyD4f2orCTYALcCSPV4w0Sf7NcF9osTndORYEOqPUE2xjgFstkRPBA8DDfvg_MDwcNfBA-b7bf--Y_nt-fMGmSE6IDUdPWKpKbQOzMpLbOl4z5blCV0T-huWWt6-_e392SVs5CAbB9vBgAA7ewAwqVOS9Ci02SzOMl2_7Gf17NTAk7OEWT_UPG-z8X8BJczusd9F_l45DF61aUoj0eCjCAzKcTIlc6E2ICXMXm7xLuPs93flfh9_Oh-egs8mJvFuDOfAsDVGJoFvRpzcV7AFH2WzYcJCD4CyxrdH7gDzjI-3Zj-B_rB-cOBL2bKMsx1lvTt5TP824_gBj7vfn152r28_Ef1l1H1I6gA1kVwVr-DdTZIG1TPNXQpZh-HIXHPbZRSQJCDkTbymLU6K6fnXU6TB1ARlD07fZYB4sVBn8n6FNVZwqfX33dvv2WHAy6ElyHIAAy69ygD8In7mFkuo7QLFrz8lpSXAdb1KsOAazXYHP6hEO1GNJuGF7Jd101VrUuG62JsOWWsq5BKUdK6FChOTKwpq05bxk8omkK1SHFDGywpRYrrB1bxTVWe8HRirK-kJCWVhiv9oPXZ5P4qVAhJtvUWy6bQvJM6zOMA0coLzE6CmKeDb_OZVZeGQEqqVYjhgyWqqOc58ierSbWHT8snDD3XOiwXp-wAcx8EuKg4_tBxRppO-gDcSzAqLB0tgEdYvWKRvG7vZoSKY-oeemcIHnIey2M1efdF9pHgYc4-EDzM1f0dAAD__6Apf4k">