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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] Argument passing is not ABI-compatible with GCC
        </td>
    </tr>

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

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

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

<pre>
    ```console
$ cat test.cc
struct X {
 alignas(16) int F[4];
};
struct Y : X {};
void f(Y);
void g(int, Y y) { f(y); }
$ g++ -S -O3 -o - test.cc
        .arch armv8-a
        .file   "test.cc"
        .text
        .align  2
        .p2align 5,,15
        .global _Z1gi1Y
        .type   _Z1gi1Y, %function
_Z1gi1Y:
.LFB0:
        .cfi_startproc
        mov     x0, x2
        mov     x1, x3
        b       _Z1f1Y
        .cfi_endproc
.LFE0:
        .size   _Z1gi1Y, .-_Z1gi1Y
        .ident  "GCC: (Ubuntu 14.2.0-19ubuntu2) 14.2.0"
        .section        .note.GNU-stack,"",@progbits
$ clang++ -S -O3 -o - test.cc
        .file   "test.cc"
        .text
        .globl  _Z1gi1Y // -- Begin function _Z1gi1Y
        .p2align        2
        .type   _Z1gi1Y,@function
_Z1gi1Y: // @_Z1gi1Y
        .cfi_startproc
// %bb.0:
        mov     x0, x1
        mov     x1, x2
        b       _Z1f1Y
.Lfunc_end0:
        .size   _Z1gi1Y, .Lfunc_end0-_Z1gi1Y
        .cfi_endproc
 // -- End function
        .ident  "Ubuntu clang version 20.1.2 (0ubuntu1)"
        .section        ".note.GNU-stack","",@progbits
        .addrsig
```
Clang is expecting `g`'s `Y` parameter to be passed in `x1`, `x2`, but GCC is expecting it to be passed in `x2`, `x3`.

If I remove the `alignas(16)`, GCC and Clang agree that it should be passed in `x1`, `x2`.

I do not know whether this is a bug in GCC or in Clang.
</pre>
<img width="1" height="1" alt="" src="http://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