[FIR] CFG: drop redundant edges

Edges from class to its functions and nested classes are redundant
and lead to extra resolution work in lazy resolve mode

^KT-59600 Fixed
This commit is contained in:
Dmitrii Gridin
2023-06-23 18:05:09 +02:00
committed by Space Team
parent df28bd1d79
commit 09ca335b7e
53 changed files with 931 additions and 763 deletions
@@ -8,14 +8,13 @@ digraph complex_kt {
0 [label="Enter class AutoCloseable" style="filled" fillcolor=red];
1 [label="Exit class AutoCloseable" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
subgraph cluster_1 {
color=blue
color=red
2 [label="Enter function close" style="filled" fillcolor=red];
3 [label="Exit function close" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
1 -> {2} [color=green];
1 -> {2} [style=dashed];
2 -> {3};
subgraph cluster_2 {
@@ -0,0 +1,106 @@
digraph nestedClass_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter class OuterClass" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter property" style="filled" fillcolor=red];
2 [label="Const: Int(1)"];
3 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_2 {
color=blue
4 [label="Enter property" style="filled" fillcolor=red];
5 [label="Access variable R|/OuterClass.outerProperty|"];
6 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_3 {
color=blue
7 [label="Enter function <init>" style="filled" fillcolor=red];
8 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
9 [label="Exit function <init>" style="filled" fillcolor=red];
}
10 [label="Exit class OuterClass" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
0 -> {10} [style=dotted];
0 -> {1 4 7} [style=dashed];
1 -> {2};
2 -> {3};
3 -> {4} [color=green];
4 -> {5};
5 -> {6};
6 -> {7} [color=green];
7 -> {8};
8 -> {9};
9 -> {10} [color=green];
subgraph cluster_4 {
color=red
11 [label="Enter function outerFunction" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
12 [label="Enter block"];
13 [label="Exit block"];
}
14 [label="Exit function outerFunction" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13};
13 -> {14};
subgraph cluster_6 {
color=red
15 [label="Enter class NestedClass" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
16 [label="Enter property" style="filled" fillcolor=red];
17 [label="Const: Int(1)"];
18 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_8 {
color=blue
19 [label="Enter property" style="filled" fillcolor=red];
20 [label="Access variable R|/OuterClass.NestedClass.nestedProperty|"];
21 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_9 {
color=blue
22 [label="Enter function <init>" style="filled" fillcolor=red];
23 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
24 [label="Exit function <init>" style="filled" fillcolor=red];
}
25 [label="Exit class NestedClass" style="filled" fillcolor=red];
}
15 -> {16} [color=green];
15 -> {25} [style=dotted];
15 -> {16 19 22} [style=dashed];
16 -> {17};
17 -> {18};
18 -> {19} [color=green];
19 -> {20};
20 -> {21};
21 -> {22} [color=green];
22 -> {23};
23 -> {24};
24 -> {25} [color=green];
subgraph cluster_10 {
color=red
26 [label="Enter function nestedFUnction" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
27 [label="Enter block"];
28 [label="Exit block"];
}
29 [label="Exit function nestedFUnction" style="filled" fillcolor=red];
}
26 -> {27};
27 -> {28};
28 -> {29};
}
@@ -0,0 +1,32 @@
FILE: nestedClass.kt
public final class OuterClass : R|kotlin/Any| {
public constructor(): R|OuterClass| {
super<R|kotlin/Any|>()
}
public final fun outerFunction(): R|kotlin/Unit| {
}
public final val outerProperty: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final val outerProperty2: R|kotlin/Int| = this@R|/OuterClass|.R|/OuterClass.outerProperty|
public get(): R|kotlin/Int|
public final class NestedClass : R|kotlin/Any| {
public constructor(): R|OuterClass.NestedClass| {
super<R|kotlin/Any|>()
}
public final fun nestedFUnction(): R|kotlin/Unit| {
}
public final val nestedProperty: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
public final val nestedProperty2: R|kotlin/Int| = this@R|/OuterClass.NestedClass|.R|/OuterClass.NestedClass.nestedProperty|
public get(): R|kotlin/Int|
}
}
@@ -0,0 +1,12 @@
// !DUMP_CFG
class OuterClass {
fun outerFunction() {}
val outerProperty = 1
val outerProperty2 = outerProperty
class NestedClass {
fun nestedFUnction() {}
val nestedProperty = 1
val nestedProperty2 = nestedProperty
}
}
@@ -64,17 +64,6 @@ digraph postponedLambdaInConstructor_kt {
}
26 [label="Exit class B" style="filled" fillcolor=red];
}
subgraph cluster_9 {
color=blue
27 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
28 [label="Enter block"];
29 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
30 [label="Exit block"];
}
31 [label="Exit function foo" style="filled" fillcolor=red];
}
5 -> {6} [color=green];
5 -> {26} [style=dotted];
5 -> {6 9} [style=dashed];
@@ -101,8 +90,18 @@ digraph postponedLambdaInConstructor_kt {
23 -> {24};
24 -> {25};
25 -> {26} [color=green];
26 -> {27} [color=green];
26 -> {27} [style=dashed];
subgraph cluster_9 {
color=red
27 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
28 [label="Enter block"];
29 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
30 [label="Exit block"];
}
31 [label="Exit function foo" style="filled" fillcolor=red];
}
27 -> {28};
28 -> {29};
29 -> {30};
@@ -8,20 +8,20 @@ digraph safeCalls_kt {
0 [label="Enter class A" style="filled" fillcolor=red];
1 [label="Exit class A" style="filled" fillcolor=red];
}
subgraph cluster_1 {
color=blue
2 [label="Enter function bar" style="filled" fillcolor=red];
3 [label="Exit function bar" style="filled" fillcolor=red];
}
subgraph cluster_2 {
color=blue
4 [label="Enter function foo" style="filled" fillcolor=red];
5 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
1 -> {2 4} [color=green];
1 -> {2 4} [style=dashed];
subgraph cluster_1 {
color=red
2 [label="Enter function foo" style="filled" fillcolor=red];
3 [label="Exit function foo" style="filled" fillcolor=red];
}
2 -> {3};
subgraph cluster_2 {
color=red
4 [label="Enter function bar" style="filled" fillcolor=red];
5 [label="Exit function bar" style="filled" fillcolor=red];
}
4 -> {5};
subgraph cluster_3 {