Jump on 'continue' to condition entry points for all loops

This commit is contained in:
Svetlana Isakova
2014-08-29 21:36:16 +04:00
parent 25a0854dbd
commit 0b4f313b6d
18 changed files with 267 additions and 23 deletions
@@ -0,0 +1,41 @@
== test ==
fun test(b: Boolean) {
while (true) {
if (b) break;
continue;
}
}
---------------------
L0:
1 <START>
v(b: Boolean)
magic[FAKE_INITIALIZER](b: Boolean) -> <v0>
w(b|<v0>)
2 mark({ while (true) { if (b) break; continue; } })
L2 [loop entry point]:
L5 [condition entry point]:
r(true) -> <v1> PREV:[mark({ while (true) { if (b) break; continue; } }), jmp(L5 [condition entry point])]
mark(while (true) { if (b) break; continue; })
magic[VALUE_CONSUMER](true|<v1>) -> <v2>
L4 [body entry point]:
3 mark({ if (b) break; continue; })
mark(if (b) break)
r(b) -> <v3>
jf(L6 [else branch]|<v3>) NEXT:[read (Unit), jmp(L3 [loop exit point])]
jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- jmp(L7 ['if' expression result]) NEXT:[merge(if (b) break|!<v4>) -> <v5>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v3>)]
L7 ['if' expression result]:
merge(if (b) break|!<v4>) -> <v5>
jmp(L5 [condition entry point]) NEXT:[r(true) -> <v1>]
- 2 jmp(L2 [loop entry point]) NEXT:[r(true) -> <v1>] PREV:[]
L3 [loop exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point])]
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================