diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanDriver.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanDriver.kt index 1a792d84a5b..7f537cc9988 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanDriver.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanDriver.kt @@ -51,21 +51,23 @@ public fun runTopLevelPhases(konanConfig: KonanConfig, environment: KotlinCoreEn val moduleDescriptor = analyzerWithCompilerReport.analysisResult.moduleDescriptor val context = Context(konanConfig, bindingContext, moduleDescriptor) - - // Translate AST to high level IR. - val translator = Psi2IrTranslator(Psi2IrConfiguration(false)) - val module = translator.generateModule( moduleDescriptor, - environment.getSourceFiles(), bindingContext) - - context.irModule = module val phaser = PhaseManager(context) - phaser.phase(KonanPhase.OPTIMIZER) { - KonanLower(context).lower(module) - } + phaser.phase(KonanPhase.PSI_TO_IR) { + // Translate AST to high level IR. + val translator = Psi2IrTranslator(Psi2IrConfiguration(false)) + val module = translator.generateModule( moduleDescriptor, + environment.getSourceFiles(), bindingContext) - phaser.phase(KonanPhase.BITCODE) { - emitLLVM(context) + context.irModule = module + } + phaser.phase(KonanPhase.BACKEND) { + phaser.phase(KonanPhase.LOWER) { + KonanLower(context).lower() + } + phaser.phase(KonanPhase.BITCODE) { + emitLLVM(context) + } } phaser.phase(KonanPhase.LINKER) { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt index 56b8640aa8b..b31fd36d89f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLower.kt @@ -8,8 +8,8 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment internal class KonanLower(val context: Context) { - fun lower(module: IrModuleFragment) { - module.files.forEach { + fun lower() { + context.irModule!!.files.forEach { lower(it) } } @@ -20,7 +20,6 @@ internal class KonanLower(val context: Context) { phaser.phase(KonanPhase.LOWER_BUILTIN_OPERATORS) { BuiltinOperatorLowering(context).runOnFilePostfix(irFile) } - phaser.phase(KonanPhase.LOWER_SHARED_VARIABLES) { SharedVariablesLowering(context).runOnFilePostfix(irFile) } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanPhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanPhases.kt index 1519618d5b7..ff3841afbed 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanPhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanPhases.kt @@ -5,19 +5,19 @@ import org.jetbrains.kotlin.backend.konan.Context enum class KonanPhase(val description: String, var enabled: Boolean = true, var verbose: Boolean = false) { - BACKEND("All backend"), // TODO: it is unused - OPTIMIZER("IR Optimizer"), - LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"), - LOWER_SHARED_VARIABLES("Shared Variable Lowering"), - LOWER_LOCAL_FUNCTIONS("Local Function Lowering"), - LOWER_CALLABLES("Callable references Lowering"), - AUTOBOX("Autoboxing of primitive types"), - LOWER("IR Lowering"), // TODO: it is unused - BITCODE("LLVM BitCode Generation"), - RTTI("RTTI Generation"), - CODEGEN("Code Generation"), - METADATOR("Metadata Generation"), - LINKER("Link Stage"); + /* */ PSI_TO_IR("Psi to IR conversion"), + /* */ BACKEND("All backend"), + /* ... */ LOWER("IR Lowering"), + /* ... ... */ LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"), + /* ... ... */ LOWER_SHARED_VARIABLES("Shared Variable Lowering"), + /* ... ... */ LOWER_LOCAL_FUNCTIONS("Local Function Lowering"), + /* ... ... */ LOWER_CALLABLES("Callable references Lowering"), + /* ... ... */ AUTOBOX("Autoboxing of primitive types"), + /* ... */ BITCODE("LLVM BitCode Generation"), + /* ... ... */ RTTI("RTTI Generation"), + /* ... ... */ CODEGEN("Code Generation"), + /* ... ... */ METADATOR("Metadata Generation"), + /* */ LINKER("Link Stage"); } object KonanPhases {