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
+14 -14
View File
@@ -32,46 +32,46 @@ L0:
mark(try { if (f) { x = 0 } } finally { fun bar() {} })
jmp?(L2)
3 mark({ if (f) { x = 0 } })
mark(if (f) { x = 0 }) USE: in: {f=READ, x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ}
r(f) -> <v1> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ}
mark(if (f) { x = 0 }) USE: in: {f=READ, x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ}
r(f) -> <v1> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ}
jf(L3|<v1>)
4 mark({ x = 0 })
r(0) -> <v2> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ}
w(x|<v2>) INIT: in: {f=ID} out: {f=ID, x=I} USE: in: {} out: {x=ONLY_WRITTEN_NEVER_READ}
r(0) -> <v2> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ}
w(x|<v2>) INIT: in: {f=ID} out: {f=ID, x=I} USE: in: {} out: {x=ONLY_WRITTEN_NEVER_READ}
3 jmp(L4) INIT: in: {f=ID, x=I} out: {f=ID, x=I}
L3 [else branch]:
read (Unit) INIT: in: {f=ID} out: {f=ID}
L4 ['if' expression result]:
merge(if (f) { x = 0 }|!<v3>) -> <v4> INIT: in: {f=ID, x=I?} out: {f=ID, x=I?}
merge(if (f) { x = 0 }|!<v3>) -> <v4> INIT: in: {f=ID, x=I} out: {f=ID, x=I}
2 jmp?(L2)
jmp(L5)
L2 [onExceptionToFinallyBlock]:
L6 [start finally]:
3 mark({ fun bar() {} })
jmp?(L7)
d(fun bar() {}) INIT: in: {f=I?, x=I?} out: {f=I?, x=I?}
d(fun bar() {}) INIT: in: {f=I, x=I} out: {f=I, x=I}
L7 [after local declaration]:
L10 [finish finally]:
2 jmp(error) INIT: in: {f=ID, x=I?} out: {f=ID, x=I?}
2 jmp(error) INIT: in: {f=ID, x=I} out: {f=ID, x=I}
L5 [skipFinallyToErrorBlock]:
L11 [copy of L2, onExceptionToFinallyBlock]:
3 mark({ fun bar() {} })
jmp?(L12)
d(fun bar() {}) INIT: in: {f=I?, x=I?} out: {f=I?, x=I?}
d(fun bar() {}) INIT: in: {f=I, x=I} out: {f=I, x=I}
L12 [copy of L7, after local declaration]:
2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|<v4>) -> <v5> INIT: in: {f=ID, x=I?} out: {f=ID, x=I?}
2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|<v4>) -> <v5> INIT: in: {f=ID, x=I} out: {f=ID, x=I}
L1:
1 <END>
error:
<ERROR>
sink:
<SINK> INIT: in: {f=I?, x=I?} out: {f=I?, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {}
=====================
== bar ==
fun bar() {}
---------------------
L8:
4 <START> INIT: in: {f=ID, x=I?} out: {f=ID, x=I?}
4 <START> INIT: in: {f=ID, x=I} out: {f=ID, x=I}
5 mark({})
read (Unit)
L9:
@@ -79,13 +79,13 @@ L9:
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {f=I?, x=I?} out: {f=I?, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {}
=====================
== bar ==
fun bar() {}
---------------------
L2 [copy of L8, null]:
4 <START> INIT: in: {f=ID, x=I?} out: {f=ID, x=I?}
4 <START> INIT: in: {f=ID, x=I} out: {f=ID, x=I}
5 mark({})
read (Unit)
L3 [copy of L9, null]:
@@ -93,5 +93,5 @@ L3 [copy of L9, null]:
L0 [copy of error, null]:
<ERROR> INIT: in: {} out: {}
L1 [copy of sink, null]:
<SINK> INIT: in: {f=I?, x=I?} out: {f=I?, x=I?} USE: in: {} out: {}
<SINK> INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {}
=====================