[optmz] Fixed bug with EA divergence handling + test

This commit is contained in:
Igor Chevdar
2020-10-08 17:35:56 +05:00
parent cb146e06ab
commit 6fc5eea26b
3 changed files with 32 additions and 1 deletions
@@ -556,6 +556,7 @@ internal object EscapeAnalysis {
} else {
context.log { "Escape analysis was refined:\n$endResult" }
if (numberOfRuns[function]!! > 1) {
// TODO: suboptimal. May be it is possible somehow handle the entire component at once?
context.log {
"WARNING: Escape analysis for $function seems not to be converging." +
" 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) {
node.ir?.let {
val lifetime = graph.lifetimeOf(node)
+4
View File
@@ -2779,6 +2779,10 @@ task codegen_escapeAnalysis_zeroOutObjectOnAlloc(type: KonanLocalTest) {
source = "codegen/escapeAnalysis/zeroOutObjectOnAlloc.kt"
}
task codegen_escapeAnalysis_recursion(type: KonanLocalTest) {
source = "codegen/escapeAnalysis/recursion.kt"
}
task memory_var1(type: KonanLocalTest) {
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()
}