[codegen] skip generation bodies of reified inline functions

This commit is contained in:
Vasily Levchenko
2019-09-13 11:49:54 +03:00
parent 05ce6e1e84
commit 992afd5aed
@@ -639,7 +639,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
if ((declaration as? IrSimpleFunction)?.modality == Modality.ABSTRACT if ((declaration as? IrSimpleFunction)?.modality == Modality.ABSTRACT
|| declaration.isExternal || declaration.isExternal
|| body == null) || body == null
|| declaration.isReifiedInline)
return return
generateFunction(codegen, declaration, generateFunction(codegen, declaration,
@@ -1811,21 +1812,22 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
private fun IrFunction.scope(): DIScopeOpaqueRef? = if (startOffset != UNDEFINED_OFFSET) private fun IrFunction.scope(): DIScopeOpaqueRef? = if (startOffset != UNDEFINED_OFFSET)
this.scope(startLine()) else null this.scope(startLine()) else null
private val IrFunction.isReifiedInline:Boolean
get() = isInline && typeParameters.any { it.isReified }
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private fun IrFunction.scope(startLine:Int): DIScopeOpaqueRef? { private fun IrFunction.scope(startLine:Int): DIScopeOpaqueRef? {
if (!context.shouldContainLocationDebugInfo()) if (!context.shouldContainLocationDebugInfo())
return null return null
val functionLlvmValue = codegen.llvmFunctionOrNull(this) val functionLlvmValue = codegen.llvmFunctionOrNull(this)
return if (functionLlvmValue != null) { return if (!isReifiedInline && functionLlvmValue != null) {
context.debugInfo.subprograms.getOrPut(functionLlvmValue) { context.debugInfo.subprograms.getOrPut(functionLlvmValue) {
memScoped { memScoped {
val subroutineType = subroutineType(context, codegen.llvmTargetData) val subroutineType = subroutineType(context, codegen.llvmTargetData)
val functionLlvmValue = codegen.llvmFunction(this@scope) val functionLlvmValue = codegen.llvmFunction(this@scope)
diFunctionScope(name.asString(), functionLlvmValue.name!!, startLine, subroutineType).also { diFunctionScope(name.asString(), functionLlvmValue.name!!, startLine, subroutineType).also {
if (!codegen.isExternal(this@scope)) { if (!this@scope.isInline)
DIFunctionAddSubprogram(functionLlvmValue, it) DIFunctionAddSubprogram(functionLlvmValue, it)
// TODO: don't add [functionLlvmValue] itself in this case.
}
} }
} }
} as DIScopeOpaqueRef } as DIScopeOpaqueRef