The Register Calling Convention (/Gr)

You can decrease execution time if parameters to functions are passed in registers rather than on the stack. Compiling with the /Gr command-line option enables the register calling convention for an entire file. The __fastcall keyword enables the register calling convention on a function-by-function basis.

The register calling convention will produce the most speed benefits in programs that spend a significant amount of time performing function calls, such as recursive programs or programs that call functions from within loops. You should compile small programs with the /Gr option and use __fastcall on only selected functions in large programs.

Because the 80x86 processor has a limited number of registers, only the first three parameters are allocated to registers; the rest are passed using the FORTRAN/Pascal calling convention.

Note:

The compiler allocates different registers for variables declared as register and for passing arguments using the register calling convention. This calling convention will not conflict with any register variables that you may have declared.

Exercise caution when using the register calling convention for any function written in inline assembly language. Your use of registers in assembly-language could conflict with the compiler's use of registers for storing parameters.