Re: [PATCH 1/7] Fix function argument and return value locations

Simon Marchi
2020-05-25T22:14:35Z

On 2020-05-25 5:32 p.m., Hannes Domani via Gdb-patches wrote:
> You're probably right, the thing is, I was only able to test complex float
> and complex double, because gdb doesn't like complex integral types:
>
> complex int complex_int = 5 + 6i;
>
> (gdb) p complex_int
> 'complex_int' has unknown type; cast it to its declared type
> (gdb) pt complex_int
> 'complex_int' has unknown type; cast it to its declared type
>
> So I guess it should check for target-type float as well:
>        || (type->code () == TYPE_CODE_COMPLEX
>            && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_FLT))
>
> Do many people use complex int, because I personally wouldn't have expected
> that this even exists.

Err right that doesn't make sense, let's use floats instead. I see:

$ cat hello.c
#include <complex.h>

void other(float real, float imag);
void func (complex float n)
{
other(creal(n), cimag(n));
}
$ x86_64-w64-mingw32-gcc hello.c -g3 -O0 -c
$ x86_64-w64-mingw32-objdump -d hello.o

hello.o: file format pe-x86-64

Disassembly of section .text:

0000000000000000 <func>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 83 ec 20 sub $0x20,%rsp
8: 48 89 4d 10 mov %rcx,0x10(%rbp)
c: f3 0f 10 45 14 movss 0x14(%rbp),%xmm0
11: f3 0f 5a c0 cvtss2sd %xmm0,%xmm0
15: f2 0f 5a c8 cvtsd2ss %xmm0,%xmm1
19: f3 0f 10 45 10 movss 0x10(%rbp),%xmm0
1e: f3 0f 5a c0 cvtss2sd %xmm0,%xmm0
22: f2 0f 5a c0 cvtsd2ss %xmm0,%xmm0
26: e8 00 00 00 00 callq 2b <func+0x2b>
2b: 90 nop
2c: 48 83 c4 20 add $0x20,%rsp
30: 5d pop %rbp
31: c3 retq

Doesn't this suggest that the parameter gets passed through rcx? I'm not saying you
are wrong, I'm just trying to understand how things work :).

Simon