According to the AMD64 calling convention when returning an object that is stored in memory the steps are the following:
- Caller allocates memory for the returned object and passes address as a hidden parameter in
%rdi. - Callee fills in object.
- Callee returns the address of the object in
%rax.
I'm wondering why the 3rd requirement was added to the standard? The memory is already allocated by the caller, so the caller doesn't need to be reminded where it made the allocation. What's the point of returning the address of the memory in %rax?