mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 17:49:07 +02:00
* Blocks of statements are now pruned (within reason) if a raise, exit, break, continue or goto node is found
This commit is contained in:
parent
41ae52dde1
commit
e7145f5f7c
@ -796,12 +796,45 @@ implementation
|
|||||||
else if forinline or (cs_opt_level2 in current_settings.optimizerswitches) then
|
else if forinline or (cs_opt_level2 in current_settings.optimizerswitches) then
|
||||||
begin
|
begin
|
||||||
n := TStatementNode(left);
|
n := TStatementNode(left);
|
||||||
while Assigned(n) and Assigned(n.right) do
|
while Assigned(n) do
|
||||||
begin
|
begin
|
||||||
|
case n.left.nodetype of
|
||||||
|
raisen, exitn, breakn, continuen, goton:
|
||||||
|
{ Remove all subsequent statements, stopping only at a
|
||||||
|
label or asm block since code can theoretically jump
|
||||||
|
to them. Also, don't delete temp creates and deletes }
|
||||||
|
begin
|
||||||
|
last := n;
|
||||||
|
p := TStatementNode(n.Next);
|
||||||
|
while Assigned(p) do
|
||||||
|
begin
|
||||||
|
if (TStatementNode(p).left.nodetype in [labeln, asmn, tempcreaten, tempdeleten]) then
|
||||||
|
Break;
|
||||||
|
|
||||||
|
last := p;
|
||||||
|
p := TStatementNode(p.Next);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (last <> n) then
|
||||||
|
begin
|
||||||
|
last.next := nil; { Make sure we stop one before p }
|
||||||
|
n.next.Free;
|
||||||
|
n.next := p;
|
||||||
|
n := p;
|
||||||
|
Continue;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
;
|
||||||
|
end;
|
||||||
|
|
||||||
{ Look one statement ahead in case it can be deleted - we
|
{ Look one statement ahead in case it can be deleted - we
|
||||||
need the previous statement to stitch the tree correctly
|
need the previous statement to stitch the tree correctly
|
||||||
}
|
}
|
||||||
p := TStatementNode(n.Next);
|
p := TStatementNode(n.Next);
|
||||||
|
if not Assigned(p) then
|
||||||
|
Break;
|
||||||
|
|
||||||
if Assigned(p.left) then
|
if Assigned(p.left) then
|
||||||
begin
|
begin
|
||||||
case p.left.nodetype of
|
case p.left.nodetype of
|
||||||
|
Loading…
Reference in New Issue
Block a user