[K/N][codegen] Escape analysis: handled nulls more optimally
Helps with https://youtrack.jetbrains.com/issue/KT-44148
This commit is contained in:
+3
-2
@@ -182,13 +182,14 @@ internal object EscapeAnalysis {
|
|||||||
fun computeDepths(node: DataFlowIR.Node, depth: Int) {
|
fun computeDepths(node: DataFlowIR.Node, depth: Int) {
|
||||||
if (node is DataFlowIR.Node.Scope)
|
if (node is DataFlowIR.Node.Scope)
|
||||||
node.nodes.forEach { computeDepths(it, depth + 1) }
|
node.nodes.forEach { computeDepths(it, depth + 1) }
|
||||||
else
|
else if (node != DataFlowIR.Node.Null)
|
||||||
nodesRoles[node] = NodeInfo(depth)
|
nodesRoles[node] = NodeInfo(depth)
|
||||||
}
|
}
|
||||||
computeDepths(body.rootScope, Depths.ROOT_SCOPE - 1)
|
computeDepths(body.rootScope, Depths.ROOT_SCOPE - 1)
|
||||||
|
|
||||||
fun assignRole(node: DataFlowIR.Node, role: Role, infoEntry: RoleInfoEntry?) {
|
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) }
|
body.returns.values.forEach { assignRole(it.node, Role.RETURN_VALUE, null) }
|
||||||
|
|||||||
Reference in New Issue
Block a user