3 ms·
Thanks for the explanation everyone. I suppose it was my fault for interpreting "have to" as an absolute requirement rather than a preferred method.
by anonymousiam 10y ago
Thanks for the explanation everyone. I suppose it was my fault for interpreting "have to" as an absolute requirement rather than a preferred method.
- gpderetta 10y agoIt is a requirement in the sense that if the C code passes the aggregate parameter by value, the compiler is required to generate the assembler code to pass via the registers [1]. [1] inlining, calls to static functions and whole program optimization do give the compilers freedom to pick a different calling convention of course.
- anonymous_iam 10y agoI still don't understand this. If a blob of C code passes a large structure by value, doesn't it go on the stack? Why would the compiler be required to pass such an object only via the registers?
- taejo 10y agoIt's generally expected that functions compiled with different compilers (for the same target architecture) can call each other. This only works if the compilers agree on where function arguments go; since they are all required to do it in the same way, it's better to require everyone to do it the fast way rather than requiring everyone to do it the slow way.