================
@@ -794,4 +794,78 @@ TEST_F(AArch64TargetInfoTest, 
ClassifyArgumentOveralignedHFAAlign) {
   }
 }
 
+// Empty records and zero-size types are ignored as returns under all AArch64
----------------
smithp35 wrote:

I know this is existing clang behaviour but it looks wrong for C++ by the 
definition in:

https://github.com/ARM-software/abi-aa/blob/main/cppabi64/cppabi64.rst#41summary-of-differences-from-and-additions-to-the-generic-c-abi
> For the purposes of parameter passing in 
> [[AAPCS64](https://github.com/ARM-software/abi-aa/releases)], a parameter 
> whose type is an empty class shall be treated as if its type were an 
> aggregate with a single member of type unsigned byte.

and 
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#69result-return
> If the type, T, of the result of a function is such that
>
> void func(T arg)
> would require that arg be passed as a value in a register (or set of 
> registers) according to the rules in [Parameter 
> passing](https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#parameter-passing),
>  then the result is returned in the same registers as would be used for such 
> an argument.

My interpretation there is that if an Empty type is treated as if it was an 
aggregate of a single member of type unsigned byte, then it would be returned 
in w0.

>From what I can tell GCC does return a value for Empty types. For example for
```
struct Empty {};
Empty ret_empty() { return {}; }
```
I get from GCC
```
        .global _Z9ret_emptyv
        .type   _Z9ret_emptyv, %function
_Z9ret_emptyv:
.LFB0:
        .cfi_startproc
        mov     w0, 0
        ret
        .cfi_endproc
.LFE0:
        .size   _Z9ret_emptyv, .-_Z9ret_emptyv
```
but clang has just got the `ret`.

I think you've got no choice but follow existing clang behaviour here though.

I'll see if I can chase up internally if this has come up before.

https://github.com/llvm/llvm-project/pull/224476
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to