With some dead-code-elimination at PB and assembly level, this could be avoided at all.Roger Hågensen wrote:Let me re-iterate. The "hidden" return will only be replaced if "EndProcedure value" is used.
All use of ProcedureReturn inside the procedure will continue to function just like they do today.
Let me simplify this further. "EndProcedure value" let you replace the xor eax,eax with a mov eax, value
That's it. That is the only thing I'm suggesting, I'm not suggesting to change ProcedureReturn at all.
It then would be optimized automatically, without the need for syntax changes or additional syntax.
For example, all code after a major ProcedureReturn statement is dead code and can be removed
by the compiler - if control flow does not jump to a label after the ProcedureReturn statement.
Likewise, at assembly level, dead code can be eliminated if never executed and not reachable by control flow -
but all that would probably be easier with a second pass over the generated ASM.
A more simple approach:
If the last statement in a procedure is ProcedureReturn (and that's often the case),
it is not required to generate code for returning the default 0-value.
'EndProcedure Value' wouldn't be required. It is just a small optimization to the current system.
According to my understanding, you just want some more optimizations for generated procedure code.