From 9905d4023cd533361a2feae26ea78eabc8a37b42 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 10 Feb 2020 17:58:46 +0100 Subject: [PATCH] [codegen][debug info] use single compile unit for compilation --- .../backend/konan/llvm/BitcodePhases.kt | 11 +++++++++ .../kotlin/backend/konan/llvm/DebugUtils.kt | 1 + .../kotlin/backend/konan/llvm/IrToBitcode.kt | 23 ++++--------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt index 22a159629d8..aa89eb8e650 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BitcodePhases.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.* import org.jetbrains.kotlin.util.OperatorNameConventions +import kotlin.random.Random internal val contextLLVMSetupPhase = makeKonanModuleOpPhase( name = "ContextLLVMSetup", @@ -34,6 +35,16 @@ internal val contextLLVMSetupPhase = makeKonanModuleOpPhase( val llvmModule = LLVMModuleCreateWithNameInContext("out", llvmContext)!! context.llvmModule = llvmModule context.debugInfo.builder = LLVMCreateDIBuilder(llvmModule) + context.debugInfo.compilationUnit = if (context.shouldContainLocationDebugInfo()) DICreateCompilationUnit( + builder = context.debugInfo.builder, + lang = DWARF.language(context.config), + File = "kotlin-file-${Random.nextLong()}", + dir = "-", + producer = DWARF.producer, + isOptimized = 0, + flags = "", + rv = DWARF.runtimeVersion(context.config)) as DIScopeOpaqueRef? + else null } ) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt index a7e23a2563b..632b9550d8d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/DebugUtils.kt @@ -66,6 +66,7 @@ internal class DebugInfo internal constructor(override val context: Context):Con val inlinedSubprograms = mutableMapOf() var builder: DIBuilderRef? = null var module: DIModuleRef? = null + var compilationUnit: DIScopeOpaqueRef? = null var objHeaderPointerType: DITypeOpaqueRef? = null var types = mutableMapOf() diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index 101a98b17f2..100782a687c 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.module +import kotlin.random.Random internal enum class FieldStorageKind { MAIN_THREAD, @@ -504,20 +505,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map