Make redundant null check optimization independent of boxing optimization algorithm.

Run DCE after each single redundant null check optimization pass.
This commit is contained in:
Dmitry Petrov
2017-02-06 20:01:54 +03:00
parent eda43c8b45
commit 3fc106572e
20 changed files with 454 additions and 141 deletions

View File

@@ -0,0 +1,19 @@
// WITH_RUNTIME
// FILE: test.kt
fun test1() {
val n = null
n.elvis { "X1" }
"X2".elvis { "X3" }
}
// @TestKt.class:
// 0 IFNULL
// 0 IFNONNULL
// 1 X1
// 1 X2
// 0 X3
// FILE: inline.kt
inline fun <T : Any> T?.elvis(rhs: () -> T): T = this ?: rhs()