From dfa07836fd133303a1883115f265f7dc806faba2 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Tue, 27 Dec 2016 16:18:00 +0700 Subject: [PATCH] backend: add workaround for phi nodes with zero entries --- .../kotlin/backend/konan/llvm/IrToBitcode.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 b3cbdca0b35..5c3fc8e83a1 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 @@ -767,12 +767,12 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid private fun evaluateExpressionAndJump(expression: IrExpression, destination: ContinuationBlock) { val result = evaluateExpression(expression) - if (!codegen.isAfterTerminator()) { - jump(destination, result) - } else { - // Workaround for unreachable code handling. - // Note: cannot rely on checking that expression type is Nothing. - } + // It is possible to check here whether the generated code has the normal continuation path + // and do not generate any jump if not; + // however such optimization can lead to phi functions with zero entries, which is not allowed by LLVM; + // TODO: find the better solution. + + jump(destination, result) } //-------------------------------------------------------------------------//