[JVM_IR, IR] Remove more needless temporary variables.
Avoid using a separate origin for temporary variables introduced for for loops. That doesn't add anything and gives one more case for optimizations to deal with. Extend the JVM specific optimizations to remove temporary variables to deal with more cases encountered in for loops lowering.
This commit is contained in:
+3
-6
@@ -310,8 +310,7 @@ internal class HeaderProcessor(
|
||||
progressionType.elementCastFunctionName
|
||||
),
|
||||
nameHint = "inductionVariable",
|
||||
isMutable = true,
|
||||
origin = IrDeclarationOrigin.FOR_LOOP_IMPLICIT_VARIABLE
|
||||
isMutable = true
|
||||
)
|
||||
|
||||
// Due to features of PSI2IR we can obtain nullable arguments here while actually
|
||||
@@ -325,8 +324,7 @@ internal class HeaderProcessor(
|
||||
progressionType.elementCastFunctionName
|
||||
)
|
||||
),
|
||||
nameHint = "last",
|
||||
origin = IrDeclarationOrigin.FOR_LOOP_IMPLICIT_VARIABLE
|
||||
nameHint = "last"
|
||||
)
|
||||
|
||||
val stepValue = scope.createTemporaryVariable(
|
||||
@@ -336,8 +334,7 @@ internal class HeaderProcessor(
|
||||
progressionType.stepCastFunctionName
|
||||
)
|
||||
),
|
||||
nameHint = "step",
|
||||
origin = IrDeclarationOrigin.FOR_LOOP_IMPLICIT_VARIABLE
|
||||
nameHint = "step"
|
||||
)
|
||||
|
||||
return when (headerInfo) {
|
||||
|
||||
+1
-2
@@ -351,8 +351,7 @@ internal abstract class IndexedGetIterationHandler(protected val context: Common
|
||||
// This also ensures that the semantics of re-assignment of array variables used in the loop is consistent with the semantics
|
||||
// proposed in https://youtrack.jetbrains.com/issue/KT-21354.
|
||||
val arrayReference = scope.createTemporaryVariable(
|
||||
expression, nameHint = "indexedObject",
|
||||
origin = IrDeclarationOrigin.FOR_LOOP_IMPLICIT_VARIABLE
|
||||
expression, nameHint = "indexedObject"
|
||||
)
|
||||
|
||||
val last = irCall(expression.type.sizePropertyGetter).apply {
|
||||
|
||||
Reference in New Issue
Block a user