On 13/10/2021 19:33, J. Gareth Moreton via fpc-devel wrote:
I figure this would be a whole-program optimization though due to
inter-unit calls and comparisons and the like.
Usually this is an optimisation that is performed at link-time because
you don't need any compiler-level information for it. And then it can
also consider code from statically linked libraries etc. Most standard
linkers don't have support for it, but link-time optimisation frameworks
generally do.
One thing you have to be mindful of is that if the address of a routine
gets taken in any way then you cannot merge it anymore, because there
might be a comparison somewhere in the program such as
if procvar = @myproc then
..
end;
and if myproc gets merged with other routines, then this will return
true in more cases.
Jonas
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel