Is there any way to get MSVC to pass structs arguments in registers on x64?
- by Luke
For a function with signature:
struct Pair { void *v1, *v2 };
void f(Pair p);
compiled on x64, I would like Pair's fields to be passed via register, as if the function was:
void f(void *v1, void *v2);
Compiling a test with gcc 4.2.1 for x86_64 on OSX 10.6, I can see this is exactly what happens by examining the disassembly. However, compiling with MSVC 2008 for x64 on Windows, the disassembly shows that Pair is passed on the stack. I understand that platform ABIs can prevent this optimization; does anyone know any MSVC-specific annotations, calling conventions, flags, or other hacks that can get this to work?
Thank you!