[fpc-devel] (patch) An attempt to improve assignments/function result reuse

Sergei Gorelkin sergei_gorelkin at mail.ru
Tue Dec 4 11:30:18 CET 2007


Currently, when assigning types that need helper routines (records, 
Windows widestrings and variants), the compiler converts assignment into 
a helper call immediately. If this is moved from typecheckpass to pass1, 
certain assignments get the chance to be optimized away. See the patch 

I had run the testsuite with the patch, the results were the same as 
with unpatched compiler.

This works, but the desired goal is achieved only partially.
For example, in packages/base/netdb/uriparser.pp there are 4 cases that 
may (and need to) be optimized:
1) In function ParseURI(const URI: String):  TURI; - assignment to the 
function result;
2,3) In ResolveRelativeURI() - the first two statements:
   Base := ParseUri(BaseUri);
   Rel := ParseUri(RelUri);

4) In URIToFilename() - also the first statement:
   U := ParseURI(Uri);

Only the case 4 is optimized by the patch. In cases 2 and 3, I guess 
that compiler assumes that address of Base and Rel is taken (although 
actually it is taken much later). In case 1, I don't know. Maybe someone 
can give me a hint how these cases can be handled?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nld.zip
Type: application/x-zip-compressed
Size: 1540 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20071204/249f803e/attachment.bin>

More information about the fpc-devel mailing list