[Cross-platform / Bug Fix] Additional strippable block nodes
Summary
This merge request expands on the ability for block nodes to be stripped by additionally marking block nodes that are created directly from begin..end
statements (e.g. code akin to if expression then begin ... end;
could now be more efficiently simplified if expression
always evaluates to True).
For the bug fix, dogetcopy
has been overridden for TBlockNode
so the blocknodeflags
field (which contains the all-important bnf_strippable
flag) gets copied over.
These additions are needed for pure functions (!645) so while
and repeat..until
loops can be properly expanded and analysed.
System
- Processor architecture: Cross-platform
What is the current bug behavior?
N/A
What is the behavior after applying this patch?
More block nodes can be simplified in the node tree, potentially allowing more efficient code generation.
Relevant logs and/or screenshots
Under x86_64-win64, the resultant assembly language is largely the same, although procedure tcginnode.pass_generate_code;
in the ncgset
unit is more efficiently-generated under -O4
. The bug fix commit also changes the label numbers slightly in system.math.vectors.s
, making them more efficient.
Additional notes
Code to include the bnf_strippable
flag cannot be inside the statement_block
function because it is used to generate the root nodes for initialization
and finalization
sections as well as regular subroutines, and these must never be simplified (the whole point of the bnf_strippable
flag).