Fix incorrect coroutines codegen behavior

If all the suspension calls in a suspend function were "hidden"
under the for-convention (iterator/next/hasNext) calls,
control-flow didn't find them, thus supposing that there is no
suspension points and there is no need to generate a coroutine state machine

The solution is to add relevant calls to CFG

 #KT-15824 Fixed
This commit is contained in:
Denis Zharkov
2017-01-20 15:25:21 +03:00
parent 8cbea903f4
commit 02b40326cc
22 changed files with 609 additions and 291 deletions
+9 -9
View File
@@ -5,15 +5,15 @@ fun t1() {
}
}
---------------------
<v3>: Int NEW: magic[LOOP_RANGE_ITERATION](1..2|<v2>) -> <v3>
1 <v0>: Int NEW: r(1) -> <v0>
2 <v1>: Int NEW: r(2) -> <v1>
1..2 <v2>: {<: Iterable<Int>} NEW: call(1..2, rangeTo|<v0>, <v1>) -> <v2>
i <v4>: Int NEW: r(i) -> <v4>
doSmth(i) <v5>: * NEW: call(doSmth(i), doSmth|<v4>) -> <v5>
{ doSmth(i) } <v5>: * COPY
for (i in 1..2) { doSmth(i) } !<v6>: *
{ for (i in 1..2) { doSmth(i) } } !<v6>: * COPY
<v6>: Int NEW: magic[LOOP_RANGE_ITERATION](1..2|<v5>) -> <v6>
1 <v0>: Int NEW: r(1) -> <v0>
2 <v1>: Int NEW: r(2) -> <v1>
1..2 <v5>: {<: Iterable<Int>} NEW: call(1..2, next) -> <v5>
i <v7>: Int NEW: r(i) -> <v7>
doSmth(i) <v8>: * NEW: call(doSmth(i), doSmth|<v7>) -> <v8>
{ doSmth(i) } <v8>: * COPY
for (i in 1..2) { doSmth(i) } !<v9>: *
{ for (i in 1..2) { doSmth(i) } } !<v9>: * COPY
=====================
== doSmth ==
fun doSmth(i: Int) {}