FIR CFA: align reading of labels with the way they're generated

UncaughtExceptionPath label out of a finally block matches every label
that is not handled by another edge, and a labeled edge from the middle
of a finally block aborts the jump and so should merge all available
data.
This commit is contained in:
pyos
2022-12-14 10:37:27 +01:00
committed by Dmitriy Novozhilov
parent d655147c8c
commit da018e9d06
4 changed files with 25 additions and 49 deletions
@@ -921,6 +921,8 @@ class ControlFlowGraphBuilder {
val nextExitLevel = levelOfNextExceptionCatchingGraph()
val nextFinally = finallyEnterNodes.topOrNull()?.takeIf { it.level > nextExitLevel }
if (nextFinally != null) {
// `PathAwareControlFlowGraphVisitor` has a special case that this path matches any label
// that is not otherwise matched by the edges below.
addEdge(exitNode, nextFinally, label = UncaughtExceptionPath, propagateDeadness = false)
}
@@ -1289,7 +1291,7 @@ class ControlFlowGraphBuilder {
}
}
private fun addBackEdge(from: CFGNode<*>, to: CFGNode<*>, isDead: Boolean = false, label: EdgeLabel = LoopBackPath) {
private fun addBackEdge(from: CFGNode<*>, to: CFGNode<*>, isDead: Boolean = false, label: EdgeLabel = NormalPath) {
val kind = if (isDead || from.isDead || to.isDead) EdgeKind.DeadBackward else EdgeKind.CfgBackward
CFGNode.addEdge(from, to, kind, propagateDeadness = false, label = label)
}