[fpc-devel] Debugging Loop Unroll Optimization

Sven Barth pascaldragon at googlemail.com
Fri May 18 17:15:22 CEST 2018


Martok <listbox at martoks-place.de> schrieb am Fr., 18. Mai 2018, 15:40:

> > Citation: "If the loop was terminated prematurely with an exception or a
> > break statement, the loop variable retains the value it had when the
> > loop was exited."
> As a quick fix, not unrolling loops left with exit at least fixes this
> specific
> situation. This still leaves exceptions raised, but IIRC the handlers don't
> restore context anyways, we might be okay?
>
> diff --git a/compiler/optloop.pas b/compiler/optloop.pas
> index 46039ffc5a..dc714ea2cc 100644
> --- a/compiler/optloop.pas
> +++ b/compiler/optloop.pas
> @@ -76,7 +76,7 @@ unit optloop;
>
>      function checkbreakcontinue(var n:tnode; arg: pointer):
> foreachnoderesult;
>        begin
> -        if n.nodetype in [breakn,continuen] then
> +        if n.nodetype in [breakn,continuen,exitn] then
>            result:=fen_norecurse_true
>          else
>            result:=fen_false;
>
> I'll be running this on today's snapshot, see if anything else remains.
>

Maybe it should also check for goto and at least explicit raise statements?

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180518/e0c67913/attachment.html>


More information about the fpc-devel mailing list