[IR] Split const folding into necessary one and for optimizations only

In this commit we have a lot of change in test data. This was caused
by the way where we evaluate constants. We split constant evaluation
into two distinct parts: only necessary evaluations for `fir2ir`
(like const val and annotations) and optimizations for lowering.
Now we don't do all constant evaluation on `fir2ir`, but IR
dump is executed after this phase, so test data changed.

#KT-58923
This commit is contained in:
Ivan Kylchik
2023-05-28 18:43:30 +02:00
committed by Space Team
parent 8067df3c94
commit dd264cff50
96 changed files with 648 additions and 327 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
// IGNORE_BACKEND_K1: JS_IR
// IGNORE_BACKEND_K1: JS_IR_ES6
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
@@ -1,5 +1,7 @@
// TARGET_BACKEND: JS_IR
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
// TODO enable for K2 when const lowering is applied for js
fun <T> T.id() = this
const val toStringDouble1 = 1.0.<!EVALUATED("1")!>toString()<!>
@@ -1,4 +1,5 @@
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// WITH_REFLECT
annotation class A(vararg val strings: String)
@@ -1,6 +1,5 @@
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: NATIVE
// TARGET_BACKEND: JS_IR
// TODO enable for JS, Native when const lowering is applied in corresponding backends
// WITH_STDLIB
object Test {
@@ -9,7 +9,7 @@ FILE fqName:<root> fileName:/Child.kt
$this: VALUE_PARAMETER name:<this> type:<root>.Child
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in <root>.Child'
CONST String type=kotlin.String value="OK"
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:publicStaticField type:kotlin.String visibility:public [final,static]' type=kotlin.String origin=GET_PROPERTY
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in javapackage.PublicParentClass
@@ -104,7 +104,8 @@ FILE fqName:<root> fileName:/recordWithCompanion.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.Tag'
STRING_CONCATENATION type=kotlin.String
CONST String type=kotlin.String value="Tag(id="
CONST String type=kotlin.String value="Tag("
CONST String type=kotlin.String value="id="
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:id type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.Tag declared in <root>.Tag.toString' type=<root>.Tag origin=null
CONST String type=kotlin.String value=")"