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,40 @@
== test ==
fun test(b: Boolean) {
do {
if (b) break;
continue;
} while (true);
}
---------------------
L0:
1 <START>
v(b: Boolean)
magic[FAKE_INITIALIZER](b: Boolean) -> <v0>
w(b|<v0>)
2 mark({ do { if (b) break; continue; } while (true); })
3 mark(do { if (b) break; continue; } while (true))
L2 [loop entry point]:
L4 [body entry point]:
mark({ if (b) break; continue; }) PREV:[mark(do { if (b) break; continue; } while (true)), jt(L2 [loop entry point]|<v5>)]
mark(if (b) break)
r(b) -> <v1>
jf(L6 [else branch]|<v1>) 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|!<v2>) -> <v3>] PREV:[]
L6 [else branch]:
read (Unit) PREV:[jf(L6 [else branch]|<v1>)]
L7 ['if' expression result]:
merge(if (b) break|!<v2>) -> <v3>
jmp(L5 [condition entry point])
L5 [condition entry point]:
r(true) -> <v5>
jt(L2 [loop entry point]|<v5>) NEXT:[read (Unit), mark({ if (b) break; continue; })]
L3 [loop exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point]), jt(L2 [loop entry point]|<v5>)]
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================