[FIR] Fix propagating deadness for loops and when expressions
This commit is contained in:
+6
-3
@@ -206,6 +206,7 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() {
|
||||
// we should remove it
|
||||
require(lastNodes.pop() is WhenBranchConditionExitNode)
|
||||
val whenExitNode = whenExitNodes.pop()
|
||||
whenExitNode.markAsDeadIfNecessary()
|
||||
lastNodes.push(whenExitNode)
|
||||
return whenExitNode
|
||||
}
|
||||
@@ -247,6 +248,7 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() {
|
||||
addEdge(loopBlockExitNode, conditionEnterNode, propagateDeadness = false)
|
||||
}
|
||||
val loopExitNode = loopExitNodes.pop()
|
||||
loopExitNode.markAsDeadIfNecessary()
|
||||
lastNodes.push(loopExitNode)
|
||||
levelCounter--
|
||||
return loopBlockExitNode to loopExitNode
|
||||
@@ -285,7 +287,8 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() {
|
||||
require(blockEnterNode is LoopBlockEnterNode)
|
||||
addEdge(conditionExitNode, blockEnterNode, propagateDeadness = false)
|
||||
val loopExit = loopExitNodes.pop()
|
||||
addEdge(conditionExitNode, loopExit)
|
||||
addEdge(conditionExitNode, loopExit, propagateDeadness = false)
|
||||
loopExit.markAsDeadIfNecessary()
|
||||
lastNodes.push(loopExit)
|
||||
levelCounter--
|
||||
return loopExit
|
||||
@@ -310,7 +313,7 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() {
|
||||
return binaryAndExitNodes.pop().also {
|
||||
val rightNode = lastNodes.pop()
|
||||
addEdge(rightNode, it, propagateDeadness = false, isDead = it.leftOperandNode.booleanConstValue == false)
|
||||
it.isDead = it.previousNodes.all { it.isDead }
|
||||
it.markAsDeadIfNecessary()
|
||||
lastNodes.push(it)
|
||||
}
|
||||
}
|
||||
@@ -342,7 +345,7 @@ class ControlFlowGraphBuilder : ControlFlowGraphNodeBuilder() {
|
||||
return binaryOrExitNodes.pop().also {
|
||||
val rightNode = lastNodes.pop()
|
||||
addEdge(rightNode, it, propagateDeadness = false)
|
||||
it.isDead = it.previousNodes.all { it.isDead }
|
||||
it.markAsDeadIfNecessary()
|
||||
lastNodes.push(it)
|
||||
}
|
||||
}
|
||||
|
||||
+11
-10
@@ -163,11 +163,11 @@ subgraph test_4 {
|
||||
80 [shape=box label="Enter loop condition[DEAD]"];
|
||||
81 [shape=box label="Const: Boolean(true)[DEAD]"];
|
||||
82 [shape=box label="Exit loop condition[DEAD]"];
|
||||
83 [shape=box label="Exit do-whileloop[DEAD]"];
|
||||
84 [shape=box label="Access variable R|<local>/x|[DEAD]"];
|
||||
85 [shape=box label="Function call: R|<local>/x|.<Ambiguity: inc, [kotlin/inc, kotlin/inc]>#()[DEAD]"];
|
||||
86 [shape=box label="Exit block[DEAD]"];
|
||||
87 [shape=box label="Exit function test_4[DEAD]"];
|
||||
83 [shape=box label="Exit do-whileloop"];
|
||||
84 [shape=box label="Access variable R|<local>/x|"];
|
||||
85 [shape=box label="Function call: R|<local>/x|.<Ambiguity: inc, [kotlin/inc, kotlin/inc]>#()"];
|
||||
86 [shape=box label="Exit block"];
|
||||
87 [shape=box label="Exit function test_4"];
|
||||
|
||||
69 -> {70};
|
||||
70 -> {71};
|
||||
@@ -176,17 +176,18 @@ subgraph test_4 {
|
||||
73 -> {74};
|
||||
74 -> {75};
|
||||
75 -> {76};
|
||||
76 -> {83 77} [style=dotted];
|
||||
76 -> {83};
|
||||
76 -> {77} [style=dotted];
|
||||
77 -> {78} [style=dotted];
|
||||
78 -> {79} [style=dotted];
|
||||
79 -> {80} [style=dotted];
|
||||
80 -> {81} [style=dotted];
|
||||
81 -> {82} [style=dotted];
|
||||
82 -> {72 83} [style=dotted];
|
||||
83 -> {84} [style=dotted];
|
||||
84 -> {85} [style=dotted];
|
||||
85 -> {86} [style=dotted];
|
||||
86 -> {87} [style=dotted];
|
||||
83 -> {84};
|
||||
84 -> {85};
|
||||
85 -> {86};
|
||||
86 -> {87};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user