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

    <tr>
        <th>Summary</th>
        <td>
            Trivally copyable class with std::nullptr_t is returned on return slot
        </td>
    </tr>

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

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

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

<pre>
    Consider:

```cpp
#include <cstddef>
#include <type_traits>

struct S {
    std::nullptr_t n;
};

static_assert(std::is_trivially_copyable_v<S>);

S foo() {
    return {};
}
```

### Observed behavior

clang 19.1.0 x86_64 returns on return slot:
```asm
foo():
        mov     rax, rdi
        mov qword ptr [rdi], 0
        ret
```

In comparison gcc 14.2 returns in register:
```asm
foo():
        xor     eax, eax
 ret
```
https://godbolt.org/z/vaqxYoKTW

### Expected behavior

The calling convention on gcc and clang to agree. `S` is not "non-trivial for the purpose of calls" in the Itanium ABI, therefore it should be returned in registers here.

### Note

For `std::nullptr_t f() { return {}; }` clang correctly returns in a register.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2P4zYM_TXKhdjAph0nPvgwM9kAgwLtYQYoegpkmbFVKJJXoj1Jf32hxJOP2WyBBoYZiM_ke6RIGYJuLVElFs9isZ7JgTvnK0NWL7JiVrvmWL04G3RDXmRPIlmL5PNdJOdH9f10gpm2ygwNgcheVOCmoZ3Ivj_y8rGnLXupOVwRp3dgPyiGNxDL5_MJAEDgJubPnuxgTM9-y2BFNgHEcn39PwWRrNVWhkCeBa4un-uwZa9HLY05bpXrj7I2tB1F9vIWeWD5JdAb7JwTuBJY3hPyxIO3p7Pb7Mv1l-rclQyz8wN_1IH8SA3U1MlRO38LU0baFtJyns4TOKyKbZFP6QI4-5k5GMfXlnymk2F_PrnQvmBg-u3deLJeHgS-gG_0z_4fH8430LMHsXiOiMU6YpN7pCf-D7WvFpTb99Lr4Cy0SkGaz_GiREclrQ58e7P-h4yD8ydLZxnRnP2_YtUx9yGGwY3ATeua2hmeO98K3PwjcDPKH4e_3G_vfz5u2fdDT4p_0bL3jkBJY7RtQTk7kmXtLEy6pW3g3FR2IFtPNAdRJG-iSEAHsI5BIFpnv013E3bOA3cE_eB7Fwjc7hQ-CMRYuOh6ZWn1sIen59eonzvytHOeQDOEzg0mMp2qTc1tuQNE7PyxzN8d061n43zk-mD-dtex-GkaIJoimVQr5z0pNsfb5ssLnzsms6bKmjIr5YyqdIllkeX5spx11SJVDS2WKElKTItyp8oCV2WpFqmUWDczXWGCeZogIiZpWs6XebOkOk0LVAnldSnyhPZSm7kx4z42fqZDGKhK0yxbrWZG1mTCaRMiWvqAk1cgxsXoq_jRt3pog8gTowOHaxjWbKh693qMawU-10pUHwJ8aO4e7S8drt25H-vZ4E315bpq7oZ6rtxe4CYmnsy33ru_SbHAzYluELiZ9IwV_hsAAP__mUa4xg">