From 59d74b818eeef34e0aa707c4fc89ac9702fb67b5 Mon Sep 17 00:00:00 2001 From: Elena Lepilkina Date: Thu, 11 Nov 2021 15:46:16 +0300 Subject: [PATCH] [K/N] Replace safe points after EnterFrame to allow LLVM reemove repeated instructions --- .../kotlin/backend/konan/llvm/CodeGenerator.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt index 1a5215c96e3..dba05e33590 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt @@ -1516,12 +1516,17 @@ internal abstract class FunctionGenerationContext( check(!forbidRuntime) { "Attempt to init runtime where runtime usage is forbidden" } call(context.llvm.initRuntimeIfNeeded, emptyList()) } - handlePrologueExperimentalMM() + if (switchToRunnable) { + switchThreadState(Runnable) + } if (needSlots || needCleanupLandingpadAndLeaveFrame) { call(context.llvm.enterFrameFunction, listOf(slotsPhi!!, Int32(vars.skipSlots).llvm, Int32(slotCount).llvm)) } else { check(!setCurrentFrameIsCalled) } + if (context.memoryModel == MemoryModel.EXPERIMENTAL && !forbidRuntime) { + call(context.llvm.Kotlin_mm_safePointFunctionPrologue, emptyList()) + } resetDebugLocation() br(entryBb) } @@ -1575,15 +1580,6 @@ internal abstract class FunctionGenerationContext( handleEpilogueExperimentalMM() } - private fun handlePrologueExperimentalMM() { - if (switchToRunnable) { - switchThreadState(Runnable) - } - if (context.memoryModel == MemoryModel.EXPERIMENTAL && !forbidRuntime) { - call(context.llvm.Kotlin_mm_safePointFunctionPrologue, emptyList()) - } - } - private fun handleEpilogueExperimentalMM() { if (switchToRunnable) { check(!forbidRuntime) { "Generating a bridge when runtime is forbidden" }