[FIR] Support PreliminaryLoopVisitor in FIR DFA

This commit is contained in:
Dmitriy Novozhilov
2021-02-11 17:42:30 +03:00
parent 0e46a961a3
commit 5711a8d610
34 changed files with 294 additions and 106 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
open class A {
fun Foo() {
@@ -23,4 +22,4 @@ fun box(): String {
test.Foo()
return "OK"
}
}
+43
View File
@@ -0,0 +1,43 @@
// ISSUE: KT-44804
// WITH_STDLIB
abstract class AbstractInsnNode(val next: AbstractInsnNode? = null)
class LineNumberNode(next: AbstractInsnNode? = null) : AbstractInsnNode(next) {
val line: Int = 1
}
class LabelNode() : AbstractInsnNode(null)
fun isDeadLineNumber(insn: LineNumberNode, index: Int, frames: Array<out Any?>): Boolean {
// Line number node is "dead" if the corresponding line number interval
// contains at least one "dead" meaningful instruction and no "live" meaningful instructions.
var finger: AbstractInsnNode = insn
var fingerIndex = index
var hasDeadInsn = false
loop@ while (true) {
finger = finger.next ?: break
fingerIndex++
when (finger) {
is LabelNode ->
continue@loop
is LineNumberNode ->
if (finger.line != insn.line) return hasDeadInsn
else -> {
if (frames[fingerIndex] != null) return false
hasDeadInsn = true
}
}
}
return true
}
fun box(): String {
val node = LineNumberNode(
LineNumberNode(
LabelNode()
)
)
val result = isDeadLineNumber(node, 0, arrayOf(null, null, "aaa", "bbb"))
return if (result) "OK" else "fail"
}