Implement constant folding in the IR backend for JVM
The newly added pass folds the set of constant functions of the current backend, plus IrBuiltIns.
This commit is contained in:
committed by
max-kammerer
parent
7e4d33be24
commit
79fcaae991
@@ -1,3 +1,4 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
class A
|
||||
|
||||
fun foo(x: Any?) {}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
class A
|
||||
|
||||
fun foo(x: Any?) {}
|
||||
|
||||
fun box(u: Int) {
|
||||
val x: Int? = 1
|
||||
x!!
|
||||
|
||||
val z: Int? = if (u == 1) x else null
|
||||
z!!
|
||||
|
||||
foo(1 as java.lang.Integer)
|
||||
|
||||
val y: Any? = if (u == 1) x else A()
|
||||
y!!
|
||||
}
|
||||
|
||||
// 0 IFNULL
|
||||
// 1 IFNONNULL
|
||||
// 1 throwNpe
|
||||
// 0 ATHROW
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
class A
|
||||
fun box() {
|
||||
val x: A? = A()
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class A
|
||||
fun box(u: Int) {
|
||||
val x: A? = A()
|
||||
val y: A?
|
||||
if (u == 0) {
|
||||
y = x
|
||||
}
|
||||
else {
|
||||
y = null
|
||||
}
|
||||
|
||||
y!!
|
||||
}
|
||||
|
||||
// 0 IFNULL
|
||||
// 1 IFNONNULL
|
||||
// 1 throwNpe
|
||||
// 0 ATHROW
|
||||
Reference in New Issue
Block a user