Is there any way to get MSVC to pass structs arguments in registers on x64?

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-03-25T18:36:15Z Indexed on 2010/03/25 18:43 UTC
Read the original article Hit count: 369

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++