From b6f35ac44d82c116f4f7bc301bf9c901b230dd99 Mon Sep 17 00:00:00 2001 From: Elena Lepilkina Date: Wed, 26 May 2021 16:34:42 +0300 Subject: [PATCH] [K/N] Fix inlining of property setters by replacing ReturnsInsertion lowering --- .../jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt | 7 ------- .../org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt | 2 +- .../jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt | 8 ++++++++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt index ef7e0c00c6b..be80d07dd11 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt @@ -376,13 +376,6 @@ internal val autoboxPhase = makeKonanFileLoweringPhase( prerequisite = setOf(bridgesPhase, coroutinesPhase) ) -internal val returnsInsertionPhase = makeKonanFileLoweringPhase( - ::ReturnsInsertionLowering, - name = "ReturnsInsertion", - description = "Returns insertion for Unit functions", - prerequisite = setOf(autoboxPhase, coroutinesPhase, enumClassPhase) -) - internal val ifNullExpressionsFusionPhase = makeKonanFileLoweringPhase( ::IfNullExpressionsFusionLowering, name = "IfNullExpressionsFusionLowering", diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt index 2de15aa5bb4..e5e413bd01c 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt @@ -231,7 +231,6 @@ internal val allLoweringsPhase = NamedCompilerPhase( typeOperatorPhase, bridgesPhase, autoboxPhase, - returnsInsertionPhase, ) ), actions = setOf(defaultDumper, ::moduleValidationCallback) @@ -379,6 +378,7 @@ internal val bitcodePhase = NamedCompilerPhase( generateDebugInfoHeaderPhase then propertyAccessorInlinePhase then // Have to run after link dependencies phase, because fields // from dependencies can be changed during lowerings. + returnsInsertionPhase then escapeAnalysisPhase then localEscapeAnalysisPhase then codegenPhase then diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt index a34ec0c69bf..eca03758f86 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.common.phaser.namedUnitPhase import org.jetbrains.kotlin.backend.konan.* import org.jetbrains.kotlin.backend.konan.descriptors.GlobalHierarchyAnalysis import org.jetbrains.kotlin.backend.konan.lower.RedundantCoercionsCleaner +import org.jetbrains.kotlin.backend.konan.lower.ReturnsInsertionLowering import org.jetbrains.kotlin.backend.konan.optimizations.* import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrStatement @@ -108,6 +109,13 @@ internal val buildDFGPhase = makeKonanModuleOpPhase( } ) +internal val returnsInsertionPhase = makeKonanModuleOpPhase( + name = "ReturnsInsertion", + description = "Returns insertion for Unit functions", + prerequisite = setOf(autoboxPhase, coroutinesPhase, enumClassPhase), + op = { context, irModule -> irModule.files.forEach { ReturnsInsertionLowering(context).lower(it) } } +) + internal val devirtualizationPhase = makeKonanModuleOpPhase( name = "Devirtualization", description = "Devirtualization",