michael.vancanneyt wrote on Wed, 08 Aug 2012:
On Wed, 8 Aug 2012, Jonas Maebe wrote:
After the body of the called routine has been parsed, it would be
possible in theory (with indeed all the caveats the compiler would
have to take care of such as side effects -- note that these may
include non-obvious side-effects, such as potential overflow
exceptions and invalid pointer accesses).
You'd need to check the caller routine as well, values for parameters might
still be used after the call to the function.
There's a difference between not loading/evaluating expressions passed
as a parameter, and completely eliminating the program slice that
contributed to calculating every value used in the parameter
expression. Obviously, the latter has much more stringent requirements.
I still use ifdefs for debug messages, and have a template to
quickly insert :
{$ifdef debugmsg}SendDebug('|');{$endif debugmsg}
This way, there is no extra code in my final build.
It's possible to do that in a more compact way with a macro (the
following is used in a couple of places in the RTL):
{$macro on}
{$ifdef debugmsg}
{$define CallSendDebug:=SendDebug}
{$else}
{$define CallSendDebug:=//}
{$endif}
CallSendDebug('|');
Jonas
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel