-
Bug
-
Resolution: Future Project
-
P4
-
10
-
None
-
generic
-
generic
The controlFlowEscapes logic in Lower is wrong. it checks if ANY loop inside our loop has ANY break or continue and determines this is enough for control flow to escape.
It should really check if the breaks break out of "this" loop and the continues continue _outside_ "this" loop.
For example
while(true)
print(x);
while(true)
break;
print(y)
will get the outer loop tagged as non terminal, even though it isn't because it uses the break in the inner loop.
similarly
while(true)
continue
is really terminal, but counted as it isn't which generates NOP NOP ATHROW sequences. The continue goes to the loop header, which would conservatively tag it as non terminal if it weren't "true", but it is.
This is not stricty "wrong", but the overly conservative logic creates dead code for the landing pad that is never gone to in CodeGEnerator
It should really check if the breaks break out of "this" loop and the continues continue _outside_ "this" loop.
For example
while(true)
print(x);
while(true)
break;
print(y)
will get the outer loop tagged as non terminal, even though it isn't because it uses the break in the inner loop.
similarly
while(true)
continue
is really terminal, but counted as it isn't which generates NOP NOP ATHROW sequences. The continue goes to the loop header, which would conservatively tag it as non terminal if it weren't "true", but it is.
This is not stricty "wrong", but the overly conservative logic creates dead code for the landing pad that is never gone to in CodeGEnerator