From 653fc854614c913c30a20dd8fa4c1dd940f63f55 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Wed, 20 Oct 2021 18:09:02 +0300 Subject: [PATCH] [K/N] Move basic blocks with lazy init to middle of function CoreSymbolication heuristics assume that last instruction in function corresponds to last function line. This is not always true anyway, but with this hack this will happen more often. --- .../jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt | 9 +++++++++ .../jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt | 7 +++++++ 2 files changed, 16 insertions(+) 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 1e03d59409c..c9c7e571bf1 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 @@ -520,6 +520,15 @@ internal abstract class FunctionGenerationContext( return result } + /** + * This function shouldn't be used normally. + * It is used to move block with strange debug info in the middle of function, to avoid last debug info being too strange, + * because it will break heuristics in CoreSymbolication + */ + fun moveBlockAfterEntry(block: LLVMBasicBlockRef) { + LLVMMoveBasicBlockAfter(block, this.entryBb) + } + fun alloca(type: LLVMTypeRef?, name: String = "", variableLocation: VariableDebugLocation? = null): LLVMValueRef { if (isObjectType(type!!)) { appendingTo(localsInitBb) { diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 2d4742308e7..98356767689 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -2378,6 +2378,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map