backend: add workaround for phi nodes with zero entries

This commit is contained in:
Svyatoslav Scherbina
2016-12-27 16:18:00 +07:00
committed by SvyatoslavScherbina
parent 7797b0efdc
commit dfa07836fd
@@ -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)
}
//-------------------------------------------------------------------------//