JVM_IR: default-initialize variables visible in the LVT

See KT-36812. Aside from the problem stated there, D8 will throw out the
entire LVT if it sees a variable that has not been written to (and will
generate incorrect SSA if the slot is reused with a different type).

Note: this only fixes a FIR test because it's missing an `else -> throw`
branch, and default initialization satisfies the verifier and masks the
incorrect control flow.
This commit is contained in:
pyos
2020-03-02 12:12:56 +01:00
committed by Dmitry Petrov
parent ecb7478794
commit 7e6d080123
18 changed files with 20 additions and 57 deletions
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// TODO KT-36812 Generate proper lifetime intervals for local variables in JVM_IR
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
@@ -22,8 +20,8 @@ fun doIt(block: () -> Unit) {
}
// 0 ISTORE 0
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$CharRef; L1 L3 0
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$CharRef;
// JVM_IR_TEMPLATES
// 0 ISTORE 0
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$CharRef; L1 L4 0
// 1 LOCALVARIABLE c Lkotlin/jvm/internal/Ref\$CharRef;