[ This question , and it answers a rather thorough general attitude to the pros and cons of transferring structures and pointer structures. This answer intends to consider the specific case mentioned in this question, i.e. An 8-byte struct vs an 8-byte pointer and an ABI that passes arguments to registers.]
64- Intel Linux ABI , 8
, .
%rdi. . ABI
.
(8- struct vs 8- )
. ..
. , , :
int
add (struct Point p)
{
return p.x + p.y;
}
.. gcc -O1, .
(x86_64 Linux gcc 5.1, -O1):
movq %rdi, %rax
sarq $32, %rax
addl %edi, %eax
ret
movl 4(%rdi), %eax
addl (%rdi), %eax
ret
, , . , . . , , , . , , , , , .
32- Linux int 4 , (8
4). , ,
4 (8- , vs 4- ).
- - .