FIR: don't flatten for loop blocks in raw FIR builder

This commit is contained in:
Mikhail Glukhikh
2021-04-16 15:47:44 +03:00
parent a736d62edd
commit 43a2ad0467
27 changed files with 1255 additions and 1105 deletions
@@ -18,11 +18,14 @@ FILE: components.kt
}
public final fun foo(list: R|kotlin/collections/List<D>|): R|kotlin/Unit| {
lval <iterator>: R|kotlin/collections/Iterator<D>| = R|<local>/list|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<D>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval <destruct>: R|D| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|D|>|()
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
{
lval <iterator>: R|kotlin/collections/Iterator<D>| = R|<local>/list|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<D>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval <destruct>: R|D| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|D|>|()
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
}
}
lval <destruct>: R|D| = R|<local>/list|.R|kotlin/collections/first|<R|D|>()
@@ -128,71 +128,76 @@ digraph flow_kt {
subgraph cluster_16 {
color=blue
56 [label="Enter block"];
57 [label="Const: Int(0)"];
58 [label="Const: Int(0)"];
59 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...)"];
60 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...).R|kotlin/ranges/IntProgression.iterator|()"];
61 [label="Variable declaration: lval <iterator>: R|kotlin/collections/IntIterator|"];
subgraph cluster_17 {
color=blue
62 [label="Enter while loop"];
57 [label="Enter block"];
58 [label="Const: Int(0)"];
59 [label="Const: Int(0)"];
60 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...)"];
61 [label="Function call: Int(0).R|kotlin/Int.rangeTo|(...).R|kotlin/ranges/IntProgression.iterator|()"];
62 [label="Variable declaration: lval <iterator>: R|kotlin/collections/IntIterator|"];
subgraph cluster_18 {
color=blue
63 [label="Enter loop condition"];
64 [label="Access variable R|<local>/<iterator>|"];
65 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
66 [label="Exit loop condition"];
}
subgraph cluster_19 {
color=blue
67 [label="Enter loop block"];
63 [label="Enter while loop"];
subgraph cluster_19 {
color=blue
64 [label="Enter loop condition"];
65 [label="Access variable R|<local>/<iterator>|"];
66 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
67 [label="Exit loop condition"];
}
subgraph cluster_20 {
color=blue
68 [label="Enter block"];
69 [label="Access variable R|<local>/<iterator>|"];
70 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()"];
71 [label="Variable declaration: lval i: R|kotlin/Int|"];
72 [label="Access variable R|<local>/x|"];
73 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
74 [label="Exit block"];
68 [label="Enter loop block"];
subgraph cluster_21 {
color=blue
69 [label="Enter block"];
70 [label="Access variable R|<local>/<iterator>|"];
71 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()"];
72 [label="Variable declaration: lval i: R|kotlin/Int|"];
73 [label="Access variable R|<local>/x|"];
74 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
75 [label="Exit block"];
}
76 [label="Exit loop block"];
}
75 [label="Exit loop block"];
77 [label="Exit whileloop"];
}
76 [label="Exit whileloop"];
78 [label="Exit block"];
}
77 [label="Access variable R|<local>/y|"];
78 [label="Function call: R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
79 [label="Exit block"];
79 [label="Access variable R|<local>/y|"];
80 [label="Function call: R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
81 [label="Exit block"];
}
80 [label="Exit when branch result"];
81 [label="Exit when"];
82 [label="Exit when branch result"];
83 [label="Exit when"];
}
subgraph cluster_21 {
subgraph cluster_22 {
color=blue
82 [label="Enter do-while loop"];
subgraph cluster_22 {
84 [label="Enter do-while loop"];
subgraph cluster_23 {
color=blue
83 [label="Enter loop block"];
subgraph cluster_23 {
85 [label="Enter loop block"];
subgraph cluster_24 {
color=blue
84 [label="Enter block"];
85 [label="Access variable R|<local>/z|"];
86 [label="Function call: R|/bar|(...)"];
87 [label="Exit block"];
86 [label="Enter block"];
87 [label="Access variable R|<local>/z|"];
88 [label="Function call: R|/bar|(...)"];
89 [label="Exit block"];
}
88 [label="Exit loop block"];
90 [label="Exit loop block"];
}
subgraph cluster_24 {
subgraph cluster_25 {
color=blue
89 [label="Enter loop condition"];
90 [label="Const: Boolean(true)"];
91 [label="Exit loop condition"];
91 [label="Enter loop condition"];
92 [label="Const: Boolean(true)"];
93 [label="Exit loop condition"];
}
92 [label="Exit do-whileloop" style="filled" fillcolor=gray];
94 [label="Exit do-whileloop" style="filled" fillcolor=gray];
}
93 [label="Exit block" style="filled" fillcolor=gray];
95 [label="Exit block" style="filled" fillcolor=gray];
}
94 [label="Exit function foo" style="filled" fillcolor=red];
96 [label="Exit function foo" style="filled" fillcolor=red];
}
20 -> {21};
21 -> {22};
@@ -216,7 +221,7 @@ digraph flow_kt {
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {94};
42 -> {96};
42 -> {43} [style=dotted];
43 -> {44} [style=dotted];
44 -> {45} [style=dotted];
@@ -229,7 +234,7 @@ digraph flow_kt {
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {81};
54 -> {83};
55 -> {56};
56 -> {57};
57 -> {58};
@@ -241,8 +246,8 @@ digraph flow_kt {
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {76 67};
67 -> {68};
66 -> {67};
67 -> {77 68};
68 -> {69};
69 -> {70};
70 -> {71};
@@ -250,8 +255,8 @@ digraph flow_kt {
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {63} [color=green style=dashed];
76 -> {77};
75 -> {76};
76 -> {64} [color=green style=dashed];
77 -> {78};
78 -> {79};
79 -> {80};
@@ -266,9 +271,11 @@ digraph flow_kt {
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {92} [style=dotted];
91 -> {83} [color=green style=dashed];
92 -> {93} [style=dotted];
91 -> {92};
92 -> {93};
93 -> {94} [style=dotted];
93 -> {85} [color=green style=dashed];
94 -> {95} [style=dotted];
95 -> {96} [style=dotted];
}
@@ -26,10 +26,13 @@ FILE: flow.kt
[StubStatement]
when () {
Boolean(true) -> {
lval <iterator>: R|kotlin/collections/IntIterator| = Int(0).R|kotlin/Int.rangeTo|(Int(0)).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
{
lval <iterator>: R|kotlin/collections/IntIterator| = Int(0).R|kotlin/Int.rangeTo|(Int(0)).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
}
R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
@@ -171,59 +171,92 @@ FILE: forLoopChecker.kt
}
public final fun test(notRange1: R|NotRange1|, notRange2: R|NotRange2|, notRange3: R|NotRange3|, notRange4: R|NotRange4|, notRange5: R|NotRange5|, notRange6: R|NotRange6|, notRange7: R|NotRange7|, notRange8: R|NotRange8|, notRange9: R|NotRange9|, range0: R|Range0|, range1: R|Range1|): R|kotlin/Unit| {
lval <iterator>: R|ERROR CLASS: Unresolved name: iterator| = R|<local>/notRange1|.<Unresolved name: iterator>#()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
{
lval <iterator>: R|ERROR CLASS: Unresolved name: iterator| = R|<local>/notRange1|.<Unresolved name: iterator>#()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
}
}
lval <iterator>: R|kotlin/Unit| = R|<local>/notRange2|.R|/NotRange2.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
{
lval <iterator>: R|kotlin/Unit| = R|<local>/notRange2|.R|/NotRange2.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
}
}
lval <iterator>: R|ImproperIterator1| = R|<local>/notRange3|.R|/NotRange3.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator1.hasNext|()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
{
lval <iterator>: R|ImproperIterator1| = R|<local>/notRange3|.R|/NotRange3.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator1.hasNext|()) {
lval i: R|ERROR CLASS: Unresolved name: next| = R|<local>/<iterator>|.<Unresolved name: next>#()
}
}
lval <iterator>: R|ImproperIterator2| = R|<local>/notRange4|.R|/NotRange4.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Boolean| = R|<local>/<iterator>|.R|/ImproperIterator2.next|()
{
lval <iterator>: R|ImproperIterator2| = R|<local>/notRange4|.R|/NotRange4.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Boolean| = R|<local>/<iterator>|.R|/ImproperIterator2.next|()
}
}
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange5|.R|/NotRange5.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
{
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange5|.R|/NotRange5.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
}
}
lval <iterator>: R|AmbiguousHasNextIterator| = R|<local>/notRange6|.R|/NotRange6.iterator|()
while(R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.next|()
{
lval <iterator>: R|AmbiguousHasNextIterator| = R|<local>/notRange6|.R|/NotRange6.iterator|()
while(R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.next|()
}
}
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange7|.R|/NotRange7.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
{
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange7|.R|/NotRange7.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
}
}
lval <iterator>: R|ImproperIterator5| = R|<local>/notRange8|.R|/NotRange8.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator5.next|()
{
lval <iterator>: R|ImproperIterator5| = R|<local>/notRange8|.R|/NotRange8.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator5.next|()
}
}
lval <iterator>: R|ImproperIterator6| = R|<local>/notRange9|.R|/NotRange9.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator6.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator6.next|()
{
lval <iterator>: R|ImproperIterator6| = R|<local>/notRange9|.R|/NotRange9.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator6.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator6.next|()
}
}
lval <iterator>: R|GoodIterator| = R|<local>/range0|.R|/Range0.iterator|()
while(R|<local>/<iterator>|.R|/GoodIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/GoodIterator.next|()
{
lval <iterator>: R|GoodIterator| = R|<local>/range0|.R|/Range0.iterator|()
while(R|<local>/<iterator>|.R|/GoodIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/GoodIterator.next|()
}
}
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Int>| = R|<local>/range1|.R|/Range1.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Int|>|()
{
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Int>| = R|<local>/range1|.R|/Range1.iterator|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Int|>|()
}
}
}
@@ -42,15 +42,18 @@ FILE: DeepCopyIrTree.kt
}
)
this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/withinScope|<R|kotlin/Unit|>(this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|, <L> = withinScope@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Pair<IrTypeParameter, IrTypeParameter>>| = this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|.R|/IrTypeParametersContainer.typeParameters|.R|kotlin/collections/zip|<R|IrTypeParameter|, R|IrTypeParameter|>(R|<local>/other|.R|/IrTypeParametersContainer.typeParameters|).R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Pair<IrTypeParameter, IrTypeParameter>>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval <destruct>: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>|>|()
lval thisTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component1: R|IrTypeParameter|>|()
lval otherTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component2: R|IrTypeParameter|>|()
R|<local>/otherTypeParameter|.R|/IrTypeParameter.superTypes|.R|kotlin/collections/mapTo|<R|IrType|, R|IrType|, R|kotlin/collections/MutableList<IrType>|>(R|<local>/thisTypeParameter|.R|/IrTypeParameter.superTypes|, <L> = mapTo@fun <anonymous>(it: R|IrType|): R|IrType| <inline=Inline, kind=UNKNOWN> {
^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/TypeRemapper.remapType|(R|<local>/it|)
{
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Pair<IrTypeParameter, IrTypeParameter>>| = this@R|/DeepCopyIrTreeWithSymbols.copyTypeParametersFrom|.R|/IrTypeParametersContainer.typeParameters|.R|kotlin/collections/zip|<R|IrTypeParameter|, R|IrTypeParameter|>(R|<local>/other|.R|/IrTypeParametersContainer.typeParameters|).R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Pair<IrTypeParameter, IrTypeParameter>>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval <destruct>: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>|>|()
lval thisTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component1: R|IrTypeParameter|>|()
lval otherTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component2: R|IrTypeParameter|>|()
R|<local>/otherTypeParameter|.R|/IrTypeParameter.superTypes|.R|kotlin/collections/mapTo|<R|IrType|, R|IrType|, R|kotlin/collections/MutableList<IrType>|>(R|<local>/thisTypeParameter|.R|/IrTypeParameter.superTypes|, <L> = mapTo@fun <anonymous>(it: R|IrType|): R|IrType| <inline=Inline, kind=UNKNOWN> {
^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/TypeRemapper.remapType|(R|<local>/it|)
}
)
}
)
}
}
@@ -44,13 +44,16 @@ FILE: valueOfOrNull.kt
}
public final inline fun <reified E : R|kotlin/Enum<E>|> valueOfOrNull(value: R|kotlin/String|): R|E?| {
lval <iterator>: R|kotlin/collections/Iterator<E>| = R|kotlin/enumValues|<R|E|>().R|SubstitutionOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<E>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval enumValue: R|E| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|E|>|()
when () {
==(R|<local>/enumValue|.R|kotlin/Enum.name|, R|<local>/value|) -> {
^valueOfOrNull R|<local>/enumValue|
{
lval <iterator>: R|kotlin/collections/Iterator<E>| = R|kotlin/enumValues|<R|E|>().R|SubstitutionOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<E>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval enumValue: R|E| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|E|>|()
when () {
==(R|<local>/enumValue|.R|kotlin/Enum.name|, R|<local>/value|) -> {
^valueOfOrNull R|<local>/enumValue|
}
}
}
}