[K/N][codegen] Escape analysis: handled nulls more optimally

Helps with https://youtrack.jetbrains.com/issue/KT-44148
This commit is contained in:
Igor Chevdar
2021-05-19 14:52:32 +05:00
parent 426ac1281d
commit 29584edcdd
@@ -182,13 +182,14 @@ internal object EscapeAnalysis {
fun computeDepths(node: DataFlowIR.Node, depth: Int) {
if (node is DataFlowIR.Node.Scope)
node.nodes.forEach { computeDepths(it, depth + 1) }
else
else if (node != DataFlowIR.Node.Null)
nodesRoles[node] = NodeInfo(depth)
}
computeDepths(body.rootScope, Depths.ROOT_SCOPE - 1)
fun assignRole(node: DataFlowIR.Node, role: Role, infoEntry: RoleInfoEntry?) {
nodesRoles[node]!!.add(role, infoEntry)
if (node != DataFlowIR.Node.Null && infoEntry?.node != DataFlowIR.Node.Null)
nodesRoles[node]!!.add(role, infoEntry)
}
body.returns.values.forEach { assignRole(it.node, Role.RETURN_VALUE, null) }