Re: [PATCH v3] [amd64] Fix AMD64 return value ABI in expression evaluation

Tom Tromey
2019-04-16T16:39:33Z

>>>>> ">" == Leszek Swirski via gdb-patches <gdb-patches@sourceware.org> writes:

>> This ABI mismatch resulted in issues when calling a function that returns
>> a class of size <16 bytes which has a base class, including issues such
>> as the "this" pointer being incorrect (as it was passed as the second
>> argument rather than the first).

I'm still looking into the problem, but this regressed an internal test
case here at AdaCore. In particular, this patch doesn't seem to treat
bitfields the same way that gcc does.

>> * amd64-tdep.c (amd64_classify_aggregate): Use cp_pass_by_reference
>> rather than a hand-rolled POD check when checking for forced MEMORY
>> classification.

This mentions cp_pass_by_reference but the patch doesn't actually
introduce a call to this function.

>> - /* 1. If the size of an object is larger than two eightbytes, or in
>> - C++, is a non-POD structure or union type, or contains
>> + /* 1. If the size of an object is larger than two eightbytes, or it has
>> unaligned fields, it has class memory. */

This area seems to differ between gcc and gdb as well. The psABI
mentions using 8 eightbytes here, but then has a complicated footnote
about the post-merge cleanup, so I'm not certain if gcc and gdb always
agree in practice.

Tom