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

    <tr>
        <th>Summary</th>
        <td>
            incorrect implementation of aapcs64
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          moon-chilled
      </td>
    </tr>
</table>

<pre>
    Quoth the [aapcs64](https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#parameter-passing-rules) (§B.6):

> If the argument is an alignment adjusted type its value is passed as a copy of the actual value. The copy will have an alignment defined as follows:

> For a Composite Type, the alignment of the copy will have 8-byte alignment if its natural alignment is ≤ 8 and 16-byte alignment if its natural alignment is ≥ 16.

> The alignment of the copy is used for applying marshaling rules.

And (§C.10):

> If the argument has an alignment of 16 then the NGRN is rounded up to the next even number.

Consider the following:

```
typedef struct {
        long __attribute__((aligned(16))) a;
        long b;
} T;

void f(long x, T y)
```

The natural alignment of T is 16, so y should be passed in x2 and x3, but llvm passes it in x1 and x2.  Gcc has the correct behaviour here.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2PozgQ_TXOpRQEJiFw4NCdnoz2sCPtKPdWgQvwyNjIH-nOv1_ZpKe7s7Or1UjIAdfzq1d-lULn5KiJWrZ_ZPunDQY_GdvOxuhtP0mlSGw6I67tX8H4CfxEwPaPiEvvqh3bPzFeT94vjpUPjJ8YP43ST6HLejMzfnr4_ufWmcG_oCXGT9jJLSLjp06ZjvHTjFLH7Rvbz7fMOs94uaDFmTzZ7RJl6nFrgyLHeAOM1-zI2cPhMasYb2L2_Inlb2v5Bf4Ykli0Y5hJe5AOUAMqOer0jeJHcJ4E-OtCIL2DC6pAERezkQB0gNCb5QrmxtX7gGrFZXCeaI2-SKVgwgt9TiBokHqlGYxS5sX9QuXJWEA4mnkxTnqC83Uhxo9rup9Ut_x32eptd_UfYXJIdWj0waL6GHDAvnBWN-xhBzWgFlBUv3N6D0WV3ddw_let0kGINznEKpdFXaUeYUbrJlTxNdn5ie9Bi3dvj1mR_z9zJ7xz1wxQVBGjE_Db1-_fohprghYkICzgTYpoevVAF9Kgw9yR_aTmaLSTgmxCriZKPd7rqfLbkz5jOwkawHkbeg_s8PgGbpTRIzw_o_dWdsHT83MslddJNgnG6yI1c3oAWXl3tHvfOTzB-UM8rhcjBQyM1wn7GrvoDNdI9iuZ6xqt-6fhZoBzvK2o5gjOwBXcZIIS0NHbn0NqeOWpk17LiOqCB6Uu8xp3IH2CFCuEZwBf-z75tHaHtdR76GjCizTBwkSWso1oS9GUDW6oLaomzw95U1ebqd0dhkaQEBXnvGj4jndVt2-wzMvqgMOh2MiW57zMD7zM87zZVdmhEXk5iEGU9b4pyo7tcppRqiyKzIwdN9K5QG21y8tmo7Aj5dIM5FzTC6Qg4zyORNvGM9sujI7tciWdd-8sXnpFrdRvFcl5URRvEb00Ol7lbaZtglXtf4zKyHj72S7W_KDeM35KOhzjp6Tz7wAAAP__Sa_KlQ">