Computer Chess Club Archives


Search

Terms

Messages

Subject: Fastcall and inline functions optimization bug in VC++?

Author: Marcus Heidkamp

Date: 01:39:15 01/14/02


To some Visual C++ 6 experts:

I tried to write a function that used the __fastcall calling convention so that
function arguments will be provided in edx and ecx registers rather than pushing
those onto the stack. Further, I wanted that function to be inlined. So far so
good.
But as I rewrote the function body in inline assembler, the compiler did not
provide the function parameters anymore! VC++ thought, the arguments were not
referenced in the function. Because they should already be in edx/ecx there is
no need to explicitly load them from the parameter list into a register using
assembler. So the compiler simply "optimized" the code by not initializing the
registers with the appropriate values when calling the function.

The only workarounds I found so far are the following:
1) Don't do __fastcall.
2) Don't do inline assembler
3) Turn off global optimization for that function.
But that is not what I want.

Has anyone experienced the same, and is there a good solution for this? E.g. can
I tell the compiler somehow, that those parameters are not explicitly, but
implicitly used?

Thanks in advance.

Marcus



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.