JVM_IR don't inline temporary val for 'when' subject
This commit is contained in:
committed by
TeamCityServer
parent
f4a1e27124
commit
f4dd75e769
+8
@@ -393,6 +393,14 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
dontTouchTemporaryVals.add(safeCall.tmpVal)
|
||||
}
|
||||
|
||||
if (expression.origin == IrStatementOrigin.WHEN) {
|
||||
// Don't optimize out 'when' subject - otherwise we might get somewhat weird debugging behavior.
|
||||
val subject = expression.statements.firstOrNull()
|
||||
if (subject is IrVariable) {
|
||||
dontTouchTemporaryVals.add(subject)
|
||||
}
|
||||
}
|
||||
|
||||
expression.transformChildren(this, data)
|
||||
removeUnnecessaryTemporaryVariables(expression.statements)
|
||||
return expression
|
||||
|
||||
+1
-6
@@ -12,14 +12,9 @@ fun box() {
|
||||
}
|
||||
|
||||
// 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.
|
||||
// JVM_IR inlines constant value subject and folds unreachable branches.
|
||||
|
||||
// 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
|
||||
Reference in New Issue
Block a user