[JVM_IR] Fix offsets in constant propagation optimization.

Loads of temporary variables that contain constants are replaced
with a copy of the constant. This avoids locals loads and stores.
However, the copy of the constant needs to have the offset of
the load and not of the original constant.

Fixes KT-41963.
This commit is contained in:
Mads Ager
2020-09-21 13:50:32 +02:00
committed by Alexander Udalov
parent f273edeb8e
commit 78483930bc
10 changed files with 94 additions and 8 deletions
+25
View File
@@ -0,0 +1,25 @@
// FILE: test.kt
fun box() {
when (1) {
2 ->
"2"
3 ->
"3"
else ->
"1"
}
}
// JVM_IR and JVM backends have different heuristics for when to use a switch.
// JVM_IR does not use a switch in this case and therefore steps to the evaluation
// of the condition for each of the cases.
// LINENUMBERS
// test.kt:4 box
// LINENUMBERS JVM_IR
// test.kt:5 box
// test.kt:7 box
// LINENUMBERS
// test.kt:10 box
// test.kt:12 box