[optmz] Fixed bug with EA divergence handling + test
This commit is contained in:
+4
-1
@@ -556,6 +556,7 @@ internal object EscapeAnalysis {
|
|||||||
} else {
|
} else {
|
||||||
context.log { "Escape analysis was refined:\n$endResult" }
|
context.log { "Escape analysis was refined:\n$endResult" }
|
||||||
if (numberOfRuns[function]!! > 1) {
|
if (numberOfRuns[function]!! > 1) {
|
||||||
|
// TODO: suboptimal. May be it is possible somehow handle the entire component at once?
|
||||||
context.log {
|
context.log {
|
||||||
"WARNING: Escape analysis for $function seems not to be converging." +
|
"WARNING: Escape analysis for $function seems not to be converging." +
|
||||||
" Assuming conservative results."
|
" Assuming conservative results."
|
||||||
@@ -571,7 +572,9 @@ internal object EscapeAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (graph in pointsToGraphs.values) {
|
pointsToGraphs.forEach { (function, graph) ->
|
||||||
|
// TODO: suboptimal.
|
||||||
|
if (function !in nodes) return@forEach
|
||||||
for (node in graph.nodes.keys) {
|
for (node in graph.nodes.keys) {
|
||||||
node.ir?.let {
|
node.ir?.let {
|
||||||
val lifetime = graph.lifetimeOf(node)
|
val lifetime = graph.lifetimeOf(node)
|
||||||
|
|||||||
@@ -2779,6 +2779,10 @@ task codegen_escapeAnalysis_zeroOutObjectOnAlloc(type: KonanLocalTest) {
|
|||||||
source = "codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt"
|
source = "codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task codegen_escapeAnalysis_recursion(type: KonanLocalTest) {
|
||||||
|
source = "codegen/escapeAnalysis/recursion.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task memory_var1(type: KonanLocalTest) {
|
task memory_var1(type: KonanLocalTest) {
|
||||||
source = "runtime/memory/var1.kt"
|
source = "runtime/memory/var1.kt"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codegen.escapeAnalysis.recursion
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
class A {
|
||||||
|
var f: A? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(k: Int, a1: A, a2: A): A {
|
||||||
|
val a3 = A()
|
||||||
|
if (k == 0)
|
||||||
|
return a1
|
||||||
|
a3.f = a1
|
||||||
|
return foo(k - 1, a2, a3)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
foo(3, A(), A()).toString()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user