Initialization analysis : more accurate handling of non-local variables while merging data #KT-14304 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-10-20 13:41:07 +03:00
parent bba34e0caa
commit a19d178867
19 changed files with 1053 additions and 51 deletions
@@ -19,7 +19,7 @@ L0:
v(val f = { x: Int -> val a = x + b }) INIT: in: {b=ID} out: {b=ID, f=D}
mark({ x: Int -> val a = x + b }) INIT: in: {b=ID, f=D} out: {b=ID, f=D}
jmp?(L2)
d({ x: Int -> val a = x + b }) INIT: in: {b=I?, f=-} out: {b=I?, f=-} USE: in: {b=READ} out: {b=READ}
d({ x: Int -> val a = x + b }) INIT: in: {b=I, f=I?} out: {b=I, f=I?} USE: in: {b=READ} out: {b=READ}
L2 [after local declaration]:
r({ x: Int -> val a = x + b }) -> <v2> INIT: in: {b=ID, f=D} out: {b=ID, f=D}
w(f|<v2>) INIT: in: {b=ID, f=D} out: {b=ID, f=ID}
@@ -54,5 +54,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=I?, f=-, x=I?} out: {b=I?, f=-, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {b=I, f=I?, x=I?} out: {b=I, f=I?, x=I?} USE: in: {} out: {}
=====================
@@ -27,10 +27,10 @@ L0:
r(x|<v2>) -> <v3>
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
2 jmp?(L3) INIT: in: {x=ID} out: {x=ID}
d(fun foo() { val b = x }) INIT: in: {x=I?} out: {x=I?} USE: in: {x=READ} out: {x=READ}
d(fun foo() { val b = x }) INIT: in: {x=I} out: {x=I} USE: in: {x=READ} out: {x=READ}
L2 [after local class]:
L3 [after local declaration]:
mark("after")
mark("after") INIT: in: {x=I?} out: {x=I?}
r("after") -> <v4>
L1:
1 <END> INIT: in: {} out: {}
@@ -56,5 +56,5 @@ L5:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=I?} out: {x=I?} USE: in: {} out: {}
<SINK> INIT: in: {x=I} out: {x=I} USE: in: {} out: {}
=====================
@@ -17,7 +17,7 @@ L0:
r(1) -> <v1> INIT: in: {b=D} out: {b=D}
w(b|<v1>) INIT: in: {b=D} out: {b=ID}
jmp?(L2) INIT: in: {b=ID} out: {b=ID}
d(fun local(x: Int) { val a = x + b }) INIT: in: {b=I?} out: {b=I?} USE: in: {b=READ} out: {b=READ}
d(fun local(x: Int) { val a = x + b }) INIT: in: {b=I} out: {b=I} USE: in: {b=READ} out: {b=READ}
L2 [after local declaration]:
mark("after") INIT: in: {b=ID} out: {b=ID}
r("after") -> <v2>
@@ -50,5 +50,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=I?, x=I?} out: {b=I?, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {}
=====================
@@ -15,7 +15,7 @@ L0:
r(1) -> <v1> INIT: in: {b=D} out: {b=D}
w(b|<v1>) INIT: in: {b=D} out: {b=ID}
jmp?(L2) INIT: in: {b=ID} out: {b=ID}
d(fun local(x: Int) = x + b) INIT: in: {b=I?} out: {b=I?} USE: in: {b=READ} out: {b=READ}
d(fun local(x: Int) = x + b) INIT: in: {b=I} out: {b=I} USE: in: {b=READ} out: {b=READ}
L2 [after local declaration]:
mark("after") INIT: in: {b=ID} out: {b=ID}
r("after") -> <v2>
@@ -44,5 +44,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=I?, x=I?} out: {b=I?, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {}
=====================
@@ -24,7 +24,7 @@ L0:
r(1) -> <v1> INIT: in: {bar=D, x=D} out: {bar=D, x=D}
w(x|<v1>) INIT: in: {bar=D, x=D} out: {bar=D, x=ID}
2 jmp?(L2) INIT: in: {bar=D} out: {bar=D}
d(fun foo() { val a = 2 }) INIT: in: {bar=-} out: {bar=-}
d(fun foo() { val a = 2 }) INIT: in: {bar=I?} out: {bar=I?}
L2 [after local declaration]:
r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> <v2> INIT: in: {bar=D} out: {bar=D}
w(bar|<v2>) INIT: in: {bar=D} out: {bar=ID}
@@ -53,5 +53,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {bar=-} out: {bar=-} USE: in: {} out: {}
<SINK> INIT: in: {bar=I?} out: {bar=I?} USE: in: {} out: {}
=====================
@@ -17,10 +17,10 @@ L0:
jmp?(L2)
v(var a : Int get() { return field } set(v: Int) { field = v }) INIT: in: {} out: {a=D}
jmp?(L3) INIT: in: {a=D} out: {a=D} USE: in: {field=ONLY_WRITTEN_NEVER_READ, field=READ} out: {field=ONLY_WRITTEN_NEVER_READ, field=READ}
d(get() { return field }) INIT: in: {a=-} out: {a=-} USE: in: {field=READ} out: {field=READ}
d(get() { return field }) INIT: in: {a=I?} out: {a=I?} USE: in: {field=READ} out: {field=READ}
L3 [after local declaration]:
jmp?(L6) INIT: in: {a=D} out: {a=D}
d(set(v: Int) { field = v }) INIT: in: {a=-, field=I?} out: {a=-, field=I?} USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ}
d(set(v: Int) { field = v }) INIT: in: {a=I?, field=I} out: {a=I?, field=I} USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ}
L1:
L2 [after local class]:
L6 [after local declaration]:
@@ -28,7 +28,7 @@ L6 [after local declaration]:
error:
<ERROR>
sink:
<SINK> INIT: in: {field=I?} out: {field=I?} USE: in: {} out: {}
<SINK> INIT: in: {field=I} out: {field=I} USE: in: {} out: {}
=====================
== get_a ==
get() {
@@ -37,15 +37,15 @@ get() {
---------------------
L4:
3 <START> INIT: in: {a=D} out: {a=D}
4 mark({ return field }) USE: in: {field=READ} out: {field=READ}
r(field) -> <v0> USE: in: {} out: {field=READ}
4 mark({ return field }) USE: in: {field=READ} out: {field=READ}
r(field) -> <v0> USE: in: {} out: {field=READ}
ret(*|<v0>) L5
L5:
3 <END>
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=-} out: {a=-} USE: in: {} out: {}
<SINK> INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {}
=====================
== set_a ==
set(v: Int) {
@@ -65,5 +65,5 @@ L8:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=-, field=I?, v=I?} out: {a=-, field=I?, v=I?} USE: in: {} out: {}
<SINK> INIT: in: {a=I?, field=I, v=I?} out: {a=I?, field=I, v=I?} USE: in: {} out: {}
=====================