CFA merge for definition / initialization : more accurate handling of unknown variables #KT-13969 Fixed

(cherry picked from commit 4a96589)
This commit is contained in:
Mikhail Glukhikh
2016-09-26 12:51:24 +03:00
committed by Mikhail Glukhikh
parent 797f7ab28e
commit 436b0ec873
28 changed files with 167 additions and 91 deletions
@@ -15,9 +15,9 @@ L0:
3 mark(do { var a = 2 } while (a > 0))
L2 [loop entry point]:
L4 [body entry point]:
mark({ var a = 2 }) INIT: in: {a=ID} out: {a=ID}
v(var a = 2)
r(2) -> <v1>
mark({ var a = 2 }) INIT: in: {a=I?} out: {a=I?}
v(var a = 2) INIT: in: {a=I?} out: {a=ID}
r(2) -> <v1> INIT: in: {a=ID} out: {a=ID}
w(a|<v1>)
L5 [body exit point]:
L6 [condition entry point]:
@@ -19,9 +19,9 @@ 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 }) USE: in: {b=READ} out: {b=READ}
d({ x: Int -> val a = x + b }) INIT: in: {b=I?, f=-} out: {b=I?, f=-} USE: in: {b=READ} out: {b=READ}
L2 [after local declaration]:
r({ x: Int -> val a = x + b }) -> <v2>
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}
mark("after") INIT: in: {b=ID, f=ID} out: {b=ID, f=ID}
r("after") -> <v3>
@@ -54,5 +54,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=ID, f=D, x=ID} out: {b=ID, f=D, x=ID} USE: in: {} out: {}
<SINK> INIT: in: {b=I?, f=-, x=I?} out: {b=I?, f=-, x=I?} USE: in: {} out: {}
=====================
@@ -27,7 +27,7 @@ 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 }) 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")
@@ -56,5 +56,5 @@ L5:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
<SINK> INIT: in: {x=I?} out: {x=I?} USE: in: {} out: {}
=====================
@@ -17,9 +17,9 @@ 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 }) 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")
mark("after") INIT: in: {b=ID} out: {b=ID}
r("after") -> <v2>
L1:
1 <END> INIT: in: {} out: {}
@@ -50,5 +50,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {} out: {}
<SINK> INIT: in: {b=I?, x=I?} out: {b=I?, x=I?} USE: in: {} out: {}
=====================
@@ -15,9 +15,9 @@ 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) 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")
mark("after") INIT: in: {b=ID} out: {b=ID}
r("after") -> <v2>
L1:
1 <END> INIT: in: {} out: {}
@@ -44,5 +44,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {} out: {}
<SINK> INIT: in: {b=I?, x=I?} out: {b=I?, x=I?} USE: in: {} out: {}
=====================
@@ -24,9 +24,9 @@ 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 })
d(fun foo() { val a = 2 }) INIT: in: {bar=-} out: {bar=-}
L2 [after local declaration]:
r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> <v2>
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}
mark("after") INIT: in: {bar=ID} out: {bar=ID}
r("after") -> <v3>
@@ -53,5 +53,5 @@ L4:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {bar=D} out: {bar=D} USE: in: {} out: {}
<SINK> INIT: in: {bar=-} out: {bar=-} USE: in: {} out: {}
=====================
@@ -16,11 +16,11 @@ L0:
2 mark({ class A { var a : Int get() { return field } set(v: Int) { field = v } } })
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 }) USE: in: {field=READ} out: {field=READ}
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}
L3 [after local declaration]:
jmp?(L6)
d(set(v: Int) { field = v }) INIT: in: {a=D, field=I} out: {a=D, field=I} USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ}
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}
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() {
@@ -45,7 +45,7 @@ L5:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=D} out: {a=D} USE: in: {} out: {}
<SINK> INIT: in: {a=-} out: {a=-} USE: in: {} out: {}
=====================
== set_a ==
set(v: Int) {
@@ -57,13 +57,13 @@ L7:
v(v: Int) INIT: in: {a=D} out: {a=D, v=D}
magic[FAKE_INITIALIZER](v: Int) -> <v0> INIT: in: {a=D, v=D} out: {a=D, v=D}
w(v|<v0>) INIT: in: {a=D, v=D} out: {a=D, v=ID}
4 mark({ field = v }) INIT: in: {a=D, v=ID} out: {a=D, v=ID} USE: in: {field=ONLY_WRITTEN_NEVER_READ, v=READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
r(v) -> <v1> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
w(field|<v1>) INIT: in: {a=D, v=ID} out: {a=D, field=I, v=ID} USE: in: {} out: {field=ONLY_WRITTEN_NEVER_READ}
4 mark({ field = v }) INIT: in: {a=D, v=ID} out: {a=D, v=ID} USE: in: {field=ONLY_WRITTEN_NEVER_READ, v=READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
r(v) -> <v1> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
w(field|<v1>) INIT: in: {a=D, v=ID} out: {a=D, field=I, v=ID} USE: in: {} out: {field=ONLY_WRITTEN_NEVER_READ}
L8:
3 <END> INIT: in: {a=D, field=I, v=ID} out: {a=D, field=I, v=ID}
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=D, field=I, v=ID} out: {a=D, field=I, v=ID} USE: in: {} out: {}
<SINK> INIT: in: {a=-, field=I?, v=I?} out: {a=-, field=I?, v=I?} USE: in: {} out: {}
=====================