[fpc-devel] Managed Types, Undefined Bhaviour
jonas at freepascal.org
Fri Jun 29 20:10:05 CEST 2018
On 29/06/18 19:03, Stefan Glienke wrote:
> Delphi does not reuse them, every call to a function generates a temp
> variable. Sure, if you call it in a loop it of course uses the same one.
That does not make any sense to me from a language design point of view.
Either the language guarantees that managed function results are
initialised to empty, or it does not. The fact that these are the same
or different temps, or if there are no temps at all, should not matter
in the least. Otherwise you are defining the behaviour of the language
in terms of the quality of the compiler's alias analysis (since if it
can prove that it does not need a temp, the function result may not be
empty on entry).
> But if you have 2 calls after each other the compiler generates two
> variables. Even if they are in seperate code branches. I have often
> enough optimized some code that caused huge prologue/epilogue just for
> temp variables of different calls where only one could have happened
> (like in a case statement).
I'm sorry, but supporting the exploitation of properties of the Delphi
code generator is not in the scope of the FPC project.
More information about the fpc-devel