diff --git a/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions b/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions index b6dac5b140b..8dd64ec31c7 100644 --- a/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions +++ b/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions @@ -40,64 +40,64 @@ L0: 1 INIT: in: {} out: {} v(dir: Direction) INIT: in: {} out: {dir=D} magic[FAKE_INITIALIZER](dir: Direction) -> INIT: in: {dir=D} out: {dir=D} - w(dir|) INIT: in: {dir=D} out: {dir=ID} USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ} + w(dir|) INIT: in: {dir=D} out: {dir=ID} USE: in: {dir=READ} out: {dir=READ} 2 mark({ val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res }) INIT: in: {dir=ID} out: {dir=ID} v(val res: Int) INIT: in: {dir=ID} out: {dir=ID, res=D} - mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} - r(dir) -> USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} + mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} + r(dir) -> mark(Direction.NORTH -> res = 1) mark(Direction.NORTH) - mark(Direction.NORTH) USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} - r(NORTH) -> USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} + mark(Direction.NORTH) + r(NORTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.NORTH|, ) -> - jmp?(L4|) USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} + jmp?(L4|) USE: in: {dir=READ, res=READ} out: {dir=READ, res=READ} L3 ['when' entry body]: - r(1) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(1) -> USE: in: {dir=READ, res=WRITTEN_AFTER_READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {dir=READ, res=READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} L4 [next 'when' entry]: mark(Direction.SOUTH -> res = 2) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} mark(Direction.SOUTH) - mark(Direction.SOUTH) USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} - r(SOUTH) -> USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} + mark(Direction.SOUTH) + r(SOUTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.SOUTH|, ) -> - jmp?(L6|) USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} + jmp?(L6|) USE: in: {dir=READ, res=READ} out: {dir=READ, res=READ} L5 ['when' entry body]: - r(2) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(2) -> USE: in: {dir=READ, res=WRITTEN_AFTER_READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {dir=READ, res=READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} L6 [next 'when' entry]: mark(Direction.WEST -> res = 3) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} mark(Direction.WEST) - mark(Direction.WEST) USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} - r(WEST) -> USE: in: {EAST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} + mark(Direction.WEST) + r(WEST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.WEST|, ) -> - jmp?(L8|) USE: in: {EAST=READ, res=READ} out: {EAST=READ, res=READ} + jmp?(L8|) USE: in: {dir=READ, res=READ} out: {dir=READ, res=READ} L7 ['when' entry body]: - r(3) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(3) -> USE: in: {dir=READ, res=WRITTEN_AFTER_READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {dir=READ, res=READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} L8 [next 'when' entry]: mark(Direction.EAST -> res = 4) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} mark(Direction.EAST) - mark(Direction.EAST) USE: in: {EAST=READ, res=READ} out: {EAST=READ, res=READ} - r(EAST) -> USE: in: {res=READ} out: {EAST=READ, res=READ} + mark(Direction.EAST) + r(EAST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.EAST|, ) -> - jmp?(L10|) USE: in: {res=READ} out: {res=READ} + jmp?(L10|) USE: in: {dir=READ, res=READ} out: {dir=READ, res=READ} L9 ['when' entry body]: - r(4) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} + r(4) -> USE: in: {dir=READ, res=WRITTEN_AFTER_READ} out: {dir=READ, res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {dir=READ, res=READ} out: {dir=READ, res=WRITTEN_AFTER_READ} jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} L10 [next 'when' entry]: magic[EXHAUSTIVE_WHEN_ELSE](when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) -> INIT: in: {dir=ID, res=D} out: {dir=ID, res=IED} L2 [after 'when' expression]: - merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!, !, !, !) -> INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} - r(res) -> USE: in: {} out: {res=READ} + merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!, !, !, !) -> INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {dir=READ, res=READ} out: {dir=READ, res=READ} + r(res) -> USE: in: {dir=READ} out: {dir=READ, res=READ} ret(*|) L1 L1: 1 INIT: in: {dir=ID} out: {dir=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {dir=I?} out: {dir=I?} USE: in: {} out: {} + USE: in: {dir=READ} out: {dir=READ} ===================== diff --git a/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions b/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions index 8fef6c3a2bc..beda1c7afb7 100644 --- a/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions +++ b/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions @@ -44,13 +44,13 @@ L0: 1 INIT: in: {} out: {} v(vararg a: Any?) INIT: in: {} out: {a=D} magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + w(a|) INIT: in: {a=D} out: {a=ID} + r(a) -> INIT: in: {a=ID} out: {a=ID} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {a=READ} out: {a=READ} +===================== diff --git a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions index 58677b74e8f..87f08e33434 100644 --- a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions +++ b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions @@ -8,7 +8,7 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ val a = 1 val f = { x: Int -> val y = x + a use(a) } }) v(val a = 1) INIT: in: {} out: {a=D} r(1) -> INIT: in: {a=D} out: {a=D} @@ -16,16 +16,16 @@ L0: v(val f = { x: Int -> val y = x + a use(a) }) INIT: in: {a=ID} out: {a=ID, f=D} mark({ x: Int -> val y = x + a use(a) }) INIT: in: {a=ID, f=D} out: {a=ID, f=D} jmp?(L2) - d({ x: Int -> val y = x + a use(a) }) INIT: in: {a=I, f=I?} out: {a=I, f=I?} USE: in: {a=READ} out: {a=READ} + d({ x: Int -> val y = x + a use(a) }) INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=D, x=ID, y=ID} L2 [after local declaration]: - r({ x: Int -> val y = x + a use(a) }) -> INIT: in: {a=ID, f=D} out: {a=ID, f=D} - w(f|) INIT: in: {a=ID, f=D} out: {a=ID, f=ID} + r({ x: Int -> val y = x + a use(a) }) -> + w(f|) INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=ID, x=ID, y=ID} L1: - 1 INIT: in: {} out: {} + 1 INIT: in: {a=ID, f=ID, x=ID, y=ID} out: {a=ID, f=ID, x=ID, y=ID} error: sink: - USE: in: {} out: {} + USE: in: {a=READ, x=READ} out: {a=READ, x=READ} ===================== == anonymous_0 == { x: Int -> @@ -39,22 +39,22 @@ L3: magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=D} w(x|) INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=ID} 4 mark(val y = x + a use(a)) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID} - v(val y = x + a) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ} - r(x) -> INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ} out: {a=READ, x=READ} + v(val y = x + a) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID, y=D} + r(x) -> INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=D} r(a) -> mark(x + a) call(x + a, plus|, ) -> - w(y|) INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=D, x=ID, y=ID} USE: in: {} out: {a=READ} + w(y|) INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=ID} + r(a) -> INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=D, x=ID, y=ID} mark(use(a)) call(use(a), use|) -> - 3 ret(*|) L4 INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID} + 3 ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I, f=I?, x=I?} out: {a=I, f=I?, x=I?} USE: in: {} out: {} + USE: in: {a=READ, x=READ} out: {a=READ, x=READ} ===================== == use == fun use(vararg a: Any?) = a @@ -63,13 +63,13 @@ L0: 1 INIT: in: {} out: {} v(vararg a: Any?) INIT: in: {} out: {a=D} magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + w(a|) INIT: in: {a=D} out: {a=ID} + r(a) -> INIT: in: {a=ID} out: {a=ID} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {a=READ} out: {a=READ} +===================== diff --git a/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions b/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions index db7d08ed818..620d1e9dc27 100644 --- a/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions +++ b/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions @@ -5,17 +5,17 @@ L0: 1 INIT: in: {} out: {} v(f: () -> Unit) INIT: in: {} out: {f=D} magic[FAKE_INITIALIZER](f: () -> Unit) -> INIT: in: {f=D} out: {f=D} - w(f|) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ} - r(f) -> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ} + w(f|) INIT: in: {f=D} out: {f=ID} + r(f) -> INIT: in: {f=ID} out: {f=ID} mark(f()) call(f(), invoke|) -> ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I?} out: {f=I?} USE: in: {} out: {} + USE: in: {f=READ} out: {f=READ} ===================== == foo == fun foo() { diff --git a/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions b/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions index 50aea77f14f..7ffbbe6a3e5 100644 --- a/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions +++ b/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions @@ -17,7 +17,7 @@ L0: w(b|) INIT: in: {a=ID, b=D} out: {a=ID, b=ID} USE: in: {} out: {b=ONLY_WRITTEN_NEVER_READ} r(42) -> INIT: in: {a=ID, b=ID} out: {a=ID, b=ID} L1: - 1 INIT: in: {} out: {} + 1 INIT: in: {a=ID} out: {a=ID} error: sink: @@ -37,18 +37,18 @@ L0: w(foo|) INIT: in: {foo=D} out: {foo=ID} 2 mark({ foo.c foo.c = 2 42 }) INIT: in: {foo=ID} out: {foo=ID} mark(foo.c) - r(foo) -> USE: in: {c=READ, foo=READ} out: {c=READ, foo=READ} - r(c|) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ, foo=READ} out: {c=READ, foo=READ} - r(foo) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ} out: {c=ONLY_WRITTEN_NEVER_READ, foo=READ} - r(2) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ} out: {c=ONLY_WRITTEN_NEVER_READ} - w(foo.c|, ) USE: in: {} out: {c=ONLY_WRITTEN_NEVER_READ} + r(foo) -> + r(c|) -> + r(foo) -> + r(2) -> + w(foo.c|, ) r(42) -> L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {foo=I?} out: {foo=I?} USE: in: {} out: {} + USE: in: {foo=READ} out: {foo=READ} ===================== == Foo == interface Foo { @@ -61,7 +61,7 @@ L0: L1: INIT: in: {c=D} out: {c=D} error: - INIT: in: {} out: {} + sink: - INIT: in: {c=-} out: {c=-} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/basic/VariablesUsage.instructions b/compiler/testData/cfg-variables/basic/VariablesUsage.instructions index 87940f1b4cf..faae6aef3d4 100644 --- a/compiler/testData/cfg-variables/basic/VariablesUsage.instructions +++ b/compiler/testData/cfg-variables/basic/VariablesUsage.instructions @@ -53,13 +53,13 @@ L0: 1 INIT: in: {} out: {} v(a: Int) INIT: in: {} out: {a=D} magic[FAKE_INITIALIZER](a: Int) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + w(a|) INIT: in: {a=D} out: {a=ID} + r(a) -> INIT: in: {a=ID} out: {a=ID} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {a=READ} out: {a=READ} +===================== diff --git a/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions b/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions index 6b5f23273a4..0d11c4d3e54 100644 --- a/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions +++ b/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions @@ -10,18 +10,18 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {length=READ} out: {length=READ} + 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ var x: String class A { init { x = "" } } x.length }) v(var x: String) INIT: in: {} out: {x=D} - jmp?(L2) INIT: in: {x=D} out: {x=D} USE: in: {length=READ, x=READ} out: {length=READ, x=READ} + jmp?(L2) INIT: in: {x=D} out: {x=D} USE: in: {x=READ} out: {x=READ} 3 mark({ x = "" }) mark("") - r("") -> USE: in: {length=READ, x=WRITTEN_AFTER_READ} out: {length=READ, x=WRITTEN_AFTER_READ} - w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {length=READ, x=READ} out: {length=READ, x=WRITTEN_AFTER_READ} + r("") -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} + w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} L2 [after local class]: - 2 mark(x.length) INIT: in: {x=I?D} out: {x=I?D} USE: in: {length=READ, x=READ} out: {length=READ, x=READ} - r(x) -> USE: in: {length=READ} out: {length=READ, x=READ} - r(length|) -> USE: in: {} out: {length=READ} + 2 mark(x.length) INIT: in: {x=I?D} out: {x=I?D} USE: in: {x=READ} out: {x=READ} + r(x) -> USE: in: {} out: {x=READ} + r(length|) -> L1: 1 INIT: in: {} out: {} error: diff --git a/compiler/testData/cfg-variables/bugs/kt10243.instructions b/compiler/testData/cfg-variables/bugs/kt10243.instructions index 70bdf82c8a4..17044411ec6 100644 --- a/compiler/testData/cfg-variables/bugs/kt10243.instructions +++ b/compiler/testData/cfg-variables/bugs/kt10243.instructions @@ -32,66 +32,66 @@ 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) -> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ} + mark(if (f) { x = 0 }) + r(f) -> jf(L3|) 4 mark({ x = 0 }) - r(0) -> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ} - w(x|) 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} + r(0) -> + w(x|) + 3 jmp(L4) L3 [else branch]: - read (Unit) INIT: in: {f=ID} out: {f=ID} + read (Unit) L4 ['if' expression result]: - merge(if (f) { x = 0 }|!) -> INIT: in: {f=ID, x=I} out: {f=ID, x=I} + merge(if (f) { x = 0 }|!) -> 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() {}) L7 [after local declaration]: L10 [finish finally]: - 2 jmp(error) INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 2 jmp(error) 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() {}) L12 [copy of L7, after local declaration]: - 2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|) -> INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|) -> L1: 1 error: sink: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {f=READ} out: {f=READ} ===================== == bar == fun bar() {} --------------------- L8: - 4 INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 4 INIT: in: {f=ID} out: {f=ID} 5 mark({}) read (Unit) L9: 4 error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {f=READ} out: {f=READ} ===================== == bar == fun bar() {} --------------------- L2 [copy of L8, null]: - 4 INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 4 INIT: in: {f=ID} out: {f=ID} 5 mark({}) read (Unit) L3 [copy of L9, null]: 4 L0 [copy of error, null]: - INIT: in: {} out: {} + L1 [copy of sink, null]: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {f=READ} out: {f=READ} ===================== diff --git a/compiler/testData/cfg-variables/bugs/kt4764.instructions b/compiler/testData/cfg-variables/bugs/kt4764.instructions index b08aa6912e0..90955a7ed90 100644 --- a/compiler/testData/cfg-variables/bugs/kt4764.instructions +++ b/compiler/testData/cfg-variables/bugs/kt4764.instructions @@ -78,27 +78,27 @@ L12 [start finally]: mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> L13 [finish finally]: - 5 mark({}) INIT: in: {} out: {} + 5 mark({}) INIT: in: {e=ID} out: {e=ID} read (Unit) 8 ret(*|) L1 USE: in: {} out: {} - 7 jmp(L11) L11 [afterCatches]: - 6 jmp(L14) INIT: in: {foo=ID} out: {foo=ID} + 6 jmp(L14) INIT: in: {e=ID, foo=ID} out: {e=ID, foo=ID} L10 [onExceptionToFinallyBlock]: 9 mark({ println(foo) // Variable 'foo' must be initialized }) USE: in: {foo=READ} out: {foo=READ} r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> - 5 mark({}) INIT: in: {} out: {} + 5 mark({}) INIT: in: {e=ID} out: {e=ID} read (Unit) 6 jmp(error) USE: in: {} out: {} L14 [skipFinallyToErrorBlock]: - 9 mark({ println(foo) // Variable 'foo' must be initialized }) INIT: in: {foo=ID} out: {foo=ID} USE: in: {foo=READ} out: {foo=READ} + 9 mark({ println(foo) // Variable 'foo' must be initialized }) INIT: in: {e=ID, foo=ID} out: {e=ID, foo=ID} USE: in: {foo=READ} out: {foo=READ} r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> 6 merge(try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized }|!, !) -> - 5 jmp(L15) INIT: in: {} out: {} + 5 jmp(L15) INIT: in: {e=ID} out: {e=ID} L8 [else branch]: read (Unit) L15 ['if' expression result]: @@ -111,7 +111,7 @@ L15 ['if' expression result]: ret(*|) L1 USE: in: {} out: {} - 4 jmp(L16) L7 [else branch]: - read (Unit) INIT: in: {} out: {} + read (Unit) INIT: in: {e=ID} out: {e=ID} L16 ['if' expression result]: merge(if (false) { if (false) { var foo: String? = null try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized } } return "fail" }|!) -> L6 ['if' expression result]: diff --git a/compiler/testData/cfg-variables/bugs/kt5469.instructions b/compiler/testData/cfg-variables/bugs/kt5469.instructions index 9b8a48de51c..6b5d5fd7807 100644 --- a/compiler/testData/cfg-variables/bugs/kt5469.instructions +++ b/compiler/testData/cfg-variables/bugs/kt5469.instructions @@ -37,9 +37,9 @@ L2 [onException]: magic[UNRESOLVED_CALL](println(foo)|, !) -> 3 jmp(L3) L3 [afterCatches]: - 2 merge(try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) }|!, ) -> INIT: in: {foo=ID} out: {foo=ID} + 2 merge(try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) }|!, ) -> L1: - 1 INIT: in: {} out: {} + 1 INIT: in: {e=ID} out: {e=ID} error: sink: diff --git a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions index 0dc5d0dc039..29e878038e6 100644 --- a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions +++ b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions @@ -11,9 +11,9 @@ L0: L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo0 == class Demo0 { @@ -31,9 +31,9 @@ L0: v(private val some = object { fun foo() { println(state) // Ok } }) INIT: in: {} out: {some=D} mark(object { fun foo() { println(state) // Ok } }) INIT: in: {some=D} out: {some=D} jmp?(L2) - d(fun foo() { println(state) // Ok }) INIT: in: {some=I?} out: {some=I?} USE: in: {state=READ} out: {state=READ} + d(fun foo() { println(state) // Ok }) USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r(object { fun foo() { println(state) // Ok } }) -> INIT: in: {some=D} out: {some=D} + r(object { fun foo() { println(state) // Ok } }) -> w(some|) INIT: in: {some=D} out: {some=ID} v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} @@ -41,9 +41,9 @@ L2 [after local declaration]: L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -53,16 +53,16 @@ fun foo() { L3: 2 INIT: in: {some=D} out: {some=D} 3 mark({ println(state) // Ok }) - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + sink: - INIT: in: {some=I?} out: {some=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo1 == class Demo1 { @@ -83,7 +83,7 @@ L0: v(private val some = object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {} out: {some=D} mark(object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {some=D} out: {some=D} jmp?(L2) - d(fun foo() { if (state) state = true println(state) // must be initialized }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true println(state) // must be initialized }) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: r(object { fun foo() { if (state) state = true println(state) // must be initialized } }) -> INIT: in: {some=D} out: {some=D} w(some|) INIT: in: {some=D} out: {some=ID} @@ -93,9 +93,9 @@ L2 [after local declaration]: L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -111,25 +111,25 @@ L3: mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} L5 [else branch]: read (Unit) INIT: in: {some=D} out: {some=D} L6 ['if' expression result]: merge(if (state) state = true|!) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + INIT: in: {some=D} out: {some=D} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {} out: {} ===================== == Demo1A == class Demo1A { @@ -169,25 +169,25 @@ L0: mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L2|) USE: in: {state=READ} out: {state=READ} + jf(L2|) magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L3) INIT: in: {state=I} out: {state=I} + r(true) -> + w(state|, ) + jmp(L3) L2 [else branch]: - read (Unit) INIT: in: {} out: {} + read (Unit) L3 ['if' expression result]: - merge(if (state) state = true|!) -> INIT: in: {state=I} out: {state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + merge(if (state) state = true|!) -> + magic[IMPLICIT_RECEIVER](state) -> + r(state|) -> mark(println(state)) call(println(state), println|) -> L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {state=I} out: {state=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo2 == class Demo2 { @@ -210,7 +210,7 @@ L0: v(private val some = object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {} out: {some=D} mark(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {some=D} out: {some=D} jmp?(L2) - d(fun foo() { if (state) state = true else state = false println(state) // OK }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true else state = false println(state) // OK }) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: r(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) -> INIT: in: {some=D} out: {some=D} w(some|) INIT: in: {some=D} out: {some=ID} @@ -220,9 +220,9 @@ L2 [after local declaration]: L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -238,29 +238,29 @@ L3: 2 INIT: in: {some=D} out: {some=D} 3 mark({ if (state) state = true else state = false println(state) // OK }) mark(if (state) state = true else state = false) - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=READ} jf(L5|) magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} L5 [else branch]: magic[IMPLICIT_RECEIVER](state) -> INIT: in: {some=D} out: {some=D} - r(false) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(false) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} L6 ['if' expression result]: merge(if (state) state = true else state = false|!, !) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + INIT: in: {some=D} out: {some=D} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {} out: {} ===================== == Demo3 == class Demo3 { @@ -280,9 +280,9 @@ L0: magic[IMPLICIT_RECEIVER](run { if (state) state = true println(state) // OK }) -> INIT: in: {some=D} out: {some=D} mark({ if (state) state = true println(state) // OK }) jmp?(L2) - d({ if (state) state = true println(state) // OK }) INIT: in: {some=I?} out: {some=I?} USE: in: {state=READ} out: {state=READ} + d({ if (state) state = true println(state) // OK }) USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r({ if (state) state = true println(state) // OK }) -> INIT: in: {some=D} out: {some=D} + r({ if (state) state = true println(state) // OK }) -> mark(run { if (state) state = true println(state) // OK }) call(run { if (state) state = true println(state) // OK }, run|, ) -> w(some|) INIT: in: {some=D} out: {some=ID} @@ -292,9 +292,9 @@ L2 [after local declaration]: L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == anonymous_0 == { @@ -310,25 +310,25 @@ L3: mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} jmp(L6) L5 [else branch]: read (Unit) L6 ['if' expression result]: merge(if (state) state = true|!) -> - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + sink: - INIT: in: {some=I?} out: {some=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == exec == fun exec(f: () -> T): T = f() @@ -337,17 +337,17 @@ L0: 1 INIT: in: {} out: {} v(f: () -> T) INIT: in: {} out: {f=D} magic[FAKE_INITIALIZER](f: () -> T) -> INIT: in: {f=D} out: {f=D} - w(f|) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ} - r(f) -> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ} + w(f|) INIT: in: {f=D} out: {f=ID} + r(f) -> INIT: in: {f=ID} out: {f=ID} mark(f()) call(f(), invoke|) -> ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I?} out: {f=I?} USE: in: {} out: {} + USE: in: {f=READ} out: {f=READ} ===================== == Demo4 == class Demo4 { @@ -366,7 +366,7 @@ L0: v(private val some = exec { if (state) state = true println(state) // must be initialized }) INIT: in: {} out: {some=D} mark({ if (state) state = true println(state) // must be initialized }) INIT: in: {some=D} out: {some=D} jmp?(L2) - d({ if (state) state = true println(state) // must be initialized }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d({ if (state) state = true println(state) // must be initialized }) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: r({ if (state) state = true println(state) // must be initialized }) -> INIT: in: {some=D} out: {some=D} mark(exec { if (state) state = true println(state) // must be initialized }) @@ -378,9 +378,9 @@ L2 [after local declaration]: L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == anonymous_1 == { @@ -396,25 +396,25 @@ L3: mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} L5 [else branch]: read (Unit) INIT: in: {some=D} out: {some=D} L6 ['if' expression result]: merge(if (state) state = true|!) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + INIT: in: {some=D} out: {some=D} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {} out: {} ===================== == Demo5 == class Demo5 { @@ -438,16 +438,16 @@ L0: v(private val some = object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {state=ID} out: {some=D, state=ID} mark(object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {some=D, state=ID} out: {some=D, state=ID} jmp?(L2) - d(fun foo() { if (state) state = true println(state) // OK }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true println(state) // OK }) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: r(object { fun foo() { if (state) state = true println(state) // OK } }) -> INIT: in: {some=D, state=ID} out: {some=D, state=ID} w(some|) INIT: in: {some=D, state=ID} out: {some=ID, state=ID} L1: INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} error: - INIT: in: {} out: {} + INIT: in: {some=ID} out: {some=ID} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {some=ID, state=I?} out: {some=ID, state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -479,7 +479,7 @@ L6 ['if' expression result]: L4: 2 error: - INIT: in: {} out: {} + INIT: in: {some=D} out: {some=D} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions index 89c0240de35..290a82da3e3 100644 --- a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions +++ b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions @@ -10,16 +10,16 @@ L0: v(val sum: (Int)->Int = { x: Int -> sum(x - 1) + x }) INIT: in: {} out: {sum=D} mark({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=D} out: {sum=D} jmp?(L2) - d({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=I?} out: {sum=I?} USE: in: {sum=READ} out: {sum=READ} + d({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=D, x=ID} out: {sum=D, x=ID} L2 [after local declaration]: - r({ x: Int -> sum(x - 1) + x }) -> INIT: in: {sum=D} out: {sum=D} - w(sum|) INIT: in: {sum=D} out: {sum=ID} + r({ x: Int -> sum(x - 1) + x }) -> + w(sum|) INIT: in: {sum=D, x=ID} out: {sum=ID, x=ID} L1: - INIT: in: {sum=ID} out: {sum=ID} + INIT: in: {sum=ID, x=ID} out: {sum=ID, x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {sum=I?} out: {sum=I?} USE: in: {} out: {} + USE: in: {sum=READ, x=READ} out: {sum=READ, x=READ} ===================== == anonymous_0 == { x: Int -> @@ -32,24 +32,24 @@ L3: magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {sum=D, x=D} out: {sum=D, x=D} w(x|) INIT: in: {sum=D, x=D} out: {sum=D, x=ID} 3 mark(sum(x - 1) + x) INIT: in: {sum=D, x=ID} out: {sum=D, x=ID} - magic[IMPLICIT_RECEIVER](sum) -> USE: in: {sum=READ, x=READ} out: {sum=READ, x=READ} - r(sum|) -> USE: in: {x=READ} out: {sum=READ, x=READ} + magic[IMPLICIT_RECEIVER](sum) -> + r(sum|) -> r(x) -> r(1) -> mark(x - 1) call(x - 1, minus|, ) -> mark(sum(x - 1)) - call(sum(x - 1), invoke|, ) -> USE: in: {x=READ} out: {x=READ} - r(x) -> USE: in: {} out: {x=READ} + call(sum(x - 1), invoke|, ) -> + r(x) -> mark(sum(x - 1) + x) call(sum(x - 1) + x, plus|, ) -> 2 ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {sum=I?, x=I?} out: {sum=I?, x=I?} USE: in: {} out: {} + USE: in: {sum=READ, x=READ} out: {sum=READ, x=READ} ===================== == A == open class A(val a: A) @@ -62,9 +62,9 @@ L0: L1: INIT: in: {a=ID} out: {a=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == TestObjectLiteral == class TestObjectLiteral { @@ -91,17 +91,17 @@ L0: magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {obj=D, x=D} out: {obj=D, x=D} r(obj|) -> w(x|) INIT: in: {obj=D, x=D} out: {obj=D, x=ID} - 1 jmp?(L2) INIT: in: {obj=D} out: {obj=D} - d(fun foo() { val y = obj }) INIT: in: {obj=I?} out: {obj=I?} USE: in: {obj=READ} out: {obj=READ} + 1 jmp?(L2) INIT: in: {obj=D, x=ID} out: {obj=D, x=ID} + d(fun foo() { val y = obj }) INIT: in: {obj=D, x=ID, y=ID} out: {obj=D, x=ID, y=ID} L2 [after local declaration]: - r(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) -> INIT: in: {obj=D} out: {obj=D} - w(obj|) INIT: in: {obj=D} out: {obj=ID} + r(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) -> + w(obj|) INIT: in: {obj=D, x=ID, y=ID} out: {obj=ID, x=ID, y=ID} L1: - INIT: in: {obj=ID} out: {obj=ID} + INIT: in: {obj=ID, x=ID, y=ID} out: {obj=ID, x=ID, y=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {obj=READ} out: {obj=READ} ===================== == foo == fun foo() { @@ -109,18 +109,18 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {obj=D} out: {obj=D} + 2 INIT: in: {obj=D, x=ID} out: {obj=D, x=ID} 3 mark({ val y = obj }) - v(val y = obj) INIT: in: {obj=D} out: {obj=D, y=D} - magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {obj=D, y=D} out: {obj=D, y=D} USE: in: {obj=READ} out: {obj=READ} - r(obj|) -> USE: in: {} out: {obj=READ} - w(y|) INIT: in: {obj=D, y=D} out: {obj=D, y=ID} + v(val y = obj) INIT: in: {obj=D, x=ID} out: {obj=D, x=ID, y=D} + magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {obj=D, x=ID, y=D} out: {obj=D, x=ID, y=D} + r(obj|) -> + w(y|) INIT: in: {obj=D, x=ID, y=D} out: {obj=D, x=ID, y=ID} L4: - 2 INIT: in: {obj=D} out: {obj=D} + 2 INIT: in: {obj=D, x=ID, y=ID} out: {obj=D, x=ID, y=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {obj=READ} out: {obj=READ} ===================== == TestOther == class TestOther { @@ -130,8 +130,8 @@ class TestOther { L0: 1 INIT: in: {} out: {} v(val x: Int = x + 1) INIT: in: {} out: {x=D} - magic[IMPLICIT_RECEIVER](x) -> INIT: in: {x=D} out: {x=D} USE: in: {x=READ} out: {x=READ} - r(x|) -> USE: in: {} out: {x=READ} + magic[IMPLICIT_RECEIVER](x) -> INIT: in: {x=D} out: {x=D} + r(x|) -> r(1) -> mark(x + 1) call(x + 1, plus|, ) -> @@ -139,7 +139,7 @@ L0: L1: INIT: in: {x=ID} out: {x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {x=I?} out: {x=I?} USE: in: {} out: {} + USE: in: {x=READ} out: {x=READ} ===================== diff --git a/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions b/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions index f24b711eae8..d5bd6fcf516 100644 --- a/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions +++ b/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions @@ -18,21 +18,21 @@ L0: v(numbers: Collection) INIT: in: {} out: {numbers=D} magic[FAKE_INITIALIZER](numbers: Collection) -> INIT: in: {numbers=D} out: {numbers=D} w(numbers|) INIT: in: {numbers=D} out: {numbers=ID} - 2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID} USE: in: {numbers=READ} out: {numbers=READ} - 3 r(numbers) -> USE: in: {} out: {numbers=READ} + 2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID} + 3 r(numbers) -> mark(numbers) call(numbers, iterator|) -> v(i) INIT: in: {numbers=ID} out: {i=D, numbers=ID} L2 [loop entry point]: L6 [condition entry point]: - mark(numbers) INIT: in: {i=I?D, numbers=ID} out: {i=I?D, numbers=ID} + mark(numbers) INIT: in: {i=D, numbers=ID} out: {i=D, numbers=ID} call(numbers, hasNext) -> jmp?(L3) mark(numbers) call(numbers, next) -> magic[LOOP_RANGE_ITERATION](numbers|) -> - w(i|) INIT: in: {i=I?D, numbers=ID} out: {i=ID, numbers=ID} - mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {} + w(i|) INIT: in: {i=D, numbers=ID} out: {i=ID, numbers=ID} + mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {numbers=READ} out: {numbers=READ} L4 [body entry point]: 4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) v(val b: Boolean) INIT: in: {i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID} @@ -43,29 +43,29 @@ L4 [body entry point]: call(1 < 2, compareTo|, ) -> jf(L7|) 5 mark({ b = false }) - r(false) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} - w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} - 4 jmp(L8) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ} + r(false) -> USE: in: {b=WRITTEN_AFTER_READ, numbers=READ} out: {b=WRITTEN_AFTER_READ, numbers=READ} + w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ, numbers=READ} out: {b=WRITTEN_AFTER_READ, numbers=READ} + 4 jmp(L8) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ, numbers=READ} out: {b=READ, numbers=READ} L7 [else branch]: 5 mark({ b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID} - r(true) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} - w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} + r(true) -> USE: in: {b=WRITTEN_AFTER_READ, numbers=READ} out: {b=WRITTEN_AFTER_READ, numbers=READ} + w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ, numbers=READ} out: {b=WRITTEN_AFTER_READ, numbers=READ} L8 ['if' expression result]: - 4 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ} - r(b) -> USE: in: {} out: {b=READ} + 4 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ, numbers=READ} out: {b=READ, numbers=READ} + r(b) -> USE: in: {numbers=READ} out: {b=READ, numbers=READ} mark(use(b)) call(use(b), use|) -> - jmp(L6) USE: in: {} out: {} + jmp(L6) USE: in: {numbers=READ} out: {numbers=READ} - 3 jmp(L2) L3 [loop exit point]: L5 [body exit point]: - read (Unit) INIT: in: {i=I?D, numbers=ID} out: {i=I?D, numbers=ID} + read (Unit) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} L1: - 1 INIT: in: {numbers=ID} out: {numbers=ID} + 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {numbers=I?} out: {numbers=I?} USE: in: {} out: {} + USE: in: {numbers=READ} out: {numbers=READ} ===================== == use == fun use(vararg a: Any?) = a @@ -74,13 +74,13 @@ L0: 1 INIT: in: {} out: {} v(vararg a: Any?) INIT: in: {} out: {a=D} magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + w(a|) INIT: in: {a=D} out: {a=ID} + r(a) -> INIT: in: {a=ID} out: {a=ID} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} + USE: in: {a=READ} out: {a=READ} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions index 30130fc9fd6..b35b6d17eec 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions @@ -11,7 +11,7 @@ L0: 1 INIT: in: {} out: {} 2 mark({ "before" for (i in 1..10) { val a = i } "after" }) mark("before") - r("before") -> USE: in: {} out: {} + r("before") -> 3 r(1) -> r(10) -> mark(1..10) @@ -21,29 +21,29 @@ L0: v(i) INIT: in: {} out: {i=D} L2 [loop entry point]: L6 [condition entry point]: - mark(1..10) INIT: in: {i=I?D} out: {i=I?D} + mark(1..10) INIT: in: {i=D} out: {i=D} call(1..10, hasNext) -> jmp?(L3) mark(1..10) call(1..10, next) -> magic[LOOP_RANGE_ITERATION](1..10|) -> - w(i|) INIT: in: {i=I?D} out: {i=ID} + w(i|) INIT: in: {i=D} out: {i=ID} mark(for (i in 1..10) { val a = i }) INIT: in: {i=ID} out: {i=ID} L4 [body entry point]: 4 mark({ val a = i }) v(val a = i) INIT: in: {i=ID} out: {a=D, i=ID} r(i) -> INIT: in: {a=D, i=ID} out: {a=D, i=ID} w(a|) INIT: in: {a=D, i=ID} out: {a=ID, i=ID} - 3 jmp(L2) INIT: in: {i=ID} out: {i=ID} USE: in: {i=READ} out: {i=READ} + 3 jmp(L2) INIT: in: {a=ID, i=ID} out: {a=ID, i=ID} L3 [loop exit point]: L5 [body exit point]: - read (Unit) INIT: in: {i=I?D} out: {i=I?D} - 2 mark("after") INIT: in: {} out: {} + read (Unit) + 2 mark("after") r("after") -> L1: 1 error: sink: - USE: in: {} out: {} + USE: in: {i=READ} out: {i=READ} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions index 683974c44bf..a2f2b273c00 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions @@ -9,7 +9,7 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" }) mark("before") r("before") -> @@ -19,18 +19,18 @@ 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=I?} out: {b=I, f=I?} USE: in: {b=READ} out: {b=READ} + d({ x: Int -> val a = x + b }) INIT: in: {a=ID, b=ID, f=D, x=ID} out: {a=ID, b=ID, f=D, x=ID} L2 [after local declaration]: - r({ x: Int -> val a = x + b }) -> INIT: in: {b=ID, f=D} out: {b=ID, f=D} - w(f|) 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({ x: Int -> val a = x + b }) -> + w(f|) INIT: in: {a=ID, b=ID, f=D, x=ID} out: {a=ID, b=ID, f=ID, x=ID} + mark("after") INIT: in: {a=ID, b=ID, f=ID, x=ID} out: {a=ID, b=ID, f=ID, x=ID} r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} ===================== == anonymous_0 == { x: Int -> @@ -43,16 +43,16 @@ L3: magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, f=D, x=D} out: {b=ID, f=D, x=D} w(x|) INIT: in: {b=ID, f=D, x=D} out: {b=ID, f=D, x=ID} 4 mark(val a = x + b) INIT: in: {b=ID, f=D, x=ID} out: {b=ID, f=D, x=ID} - v(val a = x + b) INIT: in: {b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {a=D, b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + v(val a = x + b) INIT: in: {b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} + r(x) -> INIT: in: {a=D, b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} + r(b) -> mark(x + b) call(x + b, plus|, ) -> w(a|) INIT: in: {a=D, b=ID, f=D, x=ID} out: {a=ID, b=ID, f=D, x=ID} L4: - 3 INIT: in: {b=ID, f=D, x=ID} out: {b=ID, f=D, x=ID} + 3 INIT: in: {a=ID, b=ID, f=D, x=ID} out: {a=ID, b=ID, f=D, x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, f=I?, x=I?} out: {b=I, f=I?, x=I?} USE: in: {} out: {} + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions index 2485377a635..dc8eab83f12 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions @@ -22,14 +22,14 @@ L0: v(val a = 1) INIT: in: {} out: {a=D} r(1) -> INIT: in: {a=D} out: {a=D} w(a|) INIT: in: {a=D} out: {a=ID} - 2 jmp(L3) INIT: in: {} out: {} + 2 jmp(L3) INIT: in: {a=ID} out: {a=ID} L2 [else branch]: 3 mark({ val b = 2 }) - v(val b = 2) INIT: in: {} out: {b=D} - r(2) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} + v(val b = 2) INIT: in: {a=ID} out: {a=ID, b=D} + r(2) -> INIT: in: {a=ID, b=D} out: {a=ID, b=D} + w(b|) INIT: in: {a=ID, b=D} out: {a=ID, b=ID} L3 ['if' expression result]: - 2 merge(if (true) { val a = 1 } else { val b = 2 }|!, !) -> INIT: in: {} out: {} + 2 merge(if (true) { val a = 1 } else { val b = 2 }|!, !) -> INIT: in: {a=ID, b=ID} out: {a=ID, b=ID} mark("after") r("after") -> L1: @@ -37,5 +37,5 @@ L1: error: sink: - USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions b/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions index 4e84af904ae..19bc56d1c05 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions @@ -26,18 +26,18 @@ L0: magic[IMPLICIT_RECEIVER](x) -> INIT: in: {a=D, x=ID} out: {a=D, x=ID} r(x|) -> w(a|) 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} + 2 jmp?(L3) INIT: in: {a=ID, x=ID} out: {a=ID, x=ID} + d(fun foo() { val b = x }) INIT: in: {a=ID, b=ID, x=ID} out: {a=ID, b=ID, x=ID} L2 [after local class]: L3 [after local declaration]: - mark("after") INIT: in: {x=I?} out: {x=I?} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -45,16 +45,16 @@ fun foo() { } --------------------- L4: - 3 INIT: in: {x=ID} out: {x=ID} + 3 INIT: in: {a=ID, x=ID} out: {a=ID, x=ID} 4 mark({ val b = x }) - v(val b = x) INIT: in: {x=ID} out: {b=D, x=ID} - magic[IMPLICIT_RECEIVER](x) -> INIT: in: {b=D, x=ID} out: {b=D, x=ID} USE: in: {x=READ} out: {x=READ} - r(x|) -> USE: in: {} out: {x=READ} - w(b|) INIT: in: {b=D, x=ID} out: {b=ID, x=ID} + v(val b = x) INIT: in: {a=ID, x=ID} out: {a=ID, b=D, x=ID} + magic[IMPLICIT_RECEIVER](x) -> INIT: in: {a=ID, b=D, x=ID} out: {a=ID, b=D, x=ID} + r(x|) -> + w(b|) INIT: in: {a=ID, b=D, x=ID} out: {a=ID, b=ID, x=ID} L5: - 3 INIT: in: {x=ID} out: {x=ID} + 3 INIT: in: {a=ID, b=ID, x=ID} out: {a=ID, b=ID, x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {x=I} out: {x=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions index 7698ee755fd..8985d98c48e 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions @@ -9,7 +9,7 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 fun local(x: Int) { val a = x + b } "after" }) mark("before") r("before") -> @@ -17,16 +17,16 @@ L0: r(1) -> INIT: in: {b=D} out: {b=D} w(b|) 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: {a=ID, b=ID, x=ID} out: {a=ID, b=ID, x=ID} L2 [after local declaration]: - mark("after") INIT: in: {b=ID} out: {b=ID} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} ===================== == local == fun local(x: Int) { @@ -39,16 +39,16 @@ L3: magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, x=D} out: {b=ID, x=D} w(x|) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} 4 mark({ val a = x + b }) INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} - v(val a = x + b) INIT: in: {b=ID, x=ID} out: {a=D, b=ID, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {a=D, b=ID, x=ID} out: {a=D, b=ID, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + v(val a = x + b) INIT: in: {b=ID, x=ID} out: {a=D, b=ID, x=ID} + r(x) -> INIT: in: {a=D, b=ID, x=ID} out: {a=D, b=ID, x=ID} + r(b) -> mark(x + b) call(x + b, plus|, ) -> w(a|) INIT: in: {a=D, b=ID, x=ID} out: {a=ID, b=ID, x=ID} L4: - 3 INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} + 3 INIT: in: {a=ID, b=ID, x=ID} out: {a=ID, b=ID, x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions index 003bc3b3273..41024162bf8 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions @@ -7,7 +7,7 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 fun local(x: Int) = x + b "after" }) mark("before") r("before") -> @@ -15,16 +15,16 @@ L0: r(1) -> INIT: in: {b=D} out: {b=D} w(b|) 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=ID, x=ID} out: {b=ID, x=ID} L2 [after local declaration]: - mark("after") INIT: in: {b=ID} out: {b=ID} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} ===================== == local == fun local(x: Int) = x + b @@ -33,16 +33,16 @@ L3: 3 INIT: in: {b=ID} out: {b=ID} v(x: Int) INIT: in: {b=ID} out: {b=ID, x=D} magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, x=D} out: {b=ID, x=D} - w(x|) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + w(x|) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} + r(x) -> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} + r(b) -> mark(x + b) call(x + b, plus|, ) -> ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {b=READ, x=READ} out: {b=READ, x=READ} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions b/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions index a379fa0e05b..3be2504c57f 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions @@ -22,8 +22,8 @@ L0: v(val a = 1) INIT: in: {} out: {a=D} r(1) -> INIT: in: {a=D} out: {a=D} w(a|) INIT: in: {a=D} out: {a=ID} - 2 jmp?(L3) INIT: in: {} out: {} - d(fun foo() { val b = 2 }) + 2 jmp?(L3) INIT: in: {a=ID} out: {a=ID} + d(fun foo() { val b = 2 }) INIT: in: {a=ID, b=ID} out: {a=ID, b=ID} L2 [after local class]: L3 [after local declaration]: mark("after") @@ -33,7 +33,7 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -41,15 +41,15 @@ fun foo() { } --------------------- L4: - 3 INIT: in: {} out: {} + 3 INIT: in: {a=ID} out: {a=ID} 4 mark({ val b = 2 }) - v(val b = 2) INIT: in: {} out: {b=D} - r(2) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} + v(val b = 2) INIT: in: {a=ID} out: {a=ID, b=D} + r(2) -> INIT: in: {a=ID, b=D} out: {a=ID, b=D} + w(b|) INIT: in: {a=ID, b=D} out: {a=ID, b=ID} L5: - 3 INIT: in: {} out: {} + 3 INIT: in: {a=ID, b=ID} out: {a=ID, b=ID} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions index 9bd858d4db0..0b801e86894 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions @@ -23,19 +23,19 @@ L0: v(val x = 1) INIT: in: {bar=D} out: {bar=D, x=D} r(1) -> INIT: in: {bar=D, x=D} out: {bar=D, x=D} w(x|) 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=I?} out: {bar=I?} + 2 jmp?(L2) INIT: in: {bar=D, x=ID} out: {bar=D, x=ID} + d(fun foo() { val a = 2 }) INIT: in: {a=ID, bar=D, x=ID} out: {a=ID, bar=D, x=ID} L2 [after local declaration]: - r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> INIT: in: {bar=D} out: {bar=D} - w(bar|) INIT: in: {bar=D} out: {bar=ID} - mark("after") INIT: in: {bar=ID} out: {bar=ID} + r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> + w(bar|) INIT: in: {a=ID, bar=D, x=ID} out: {a=ID, bar=ID, x=ID} + mark("after") INIT: in: {a=ID, bar=ID, x=ID} out: {a=ID, bar=ID, x=ID} r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -43,15 +43,15 @@ fun foo() { } --------------------- L3: - 3 INIT: in: {bar=D} out: {bar=D} + 3 INIT: in: {bar=D, x=ID} out: {bar=D, x=ID} 4 mark({ val a = 2 }) - v(val a = 2) INIT: in: {bar=D} out: {a=D, bar=D} - r(2) -> INIT: in: {a=D, bar=D} out: {a=D, bar=D} - w(a|) INIT: in: {a=D, bar=D} out: {a=ID, bar=D} + v(val a = 2) INIT: in: {bar=D, x=ID} out: {a=D, bar=D, x=ID} + r(2) -> INIT: in: {a=D, bar=D, x=ID} out: {a=D, bar=D, x=ID} + w(a|) INIT: in: {a=D, bar=D, x=ID} out: {a=ID, bar=D, x=ID} L4: - 3 INIT: in: {bar=D} out: {bar=D} + 3 INIT: in: {a=ID, bar=D, x=ID} out: {a=ID, bar=D, x=ID} error: - INIT: in: {} out: {} + sink: - INIT: in: {bar=I?} out: {bar=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions index 00fb06c2061..abe4cd0ad49 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions @@ -16,19 +16,19 @@ 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 }) INIT: in: {a=I?} out: {a=I?} USE: in: {field=READ} out: {field=READ} + jmp?(L3) INIT: in: {a=D} out: {a=D} + d(get() { return field }) INIT: in: {a=I?} out: {a=I?} L3 [after local declaration]: jmp?(L6) INIT: in: {a=D} out: {a=D} - 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} + d(set(v: Int) { field = v }) INIT: in: {a=I?, v=ID} out: {a=I?, v=ID} L1: L2 [after local class]: L6 [after local declaration]: - 1 INIT: in: {} out: {} + 1 INIT: in: {v=ID} out: {v=ID} error: sink: - INIT: in: {field=I} out: {field=I} USE: in: {} out: {} + USE: in: {v=READ} out: {v=READ} ===================== == get_a == get() { @@ -37,15 +37,15 @@ get() { --------------------- L4: 3 INIT: in: {a=D} out: {a=D} - 4 mark({ return field }) USE: in: {field=READ} out: {field=READ} - r(field) -> USE: in: {} out: {field=READ} + 4 mark({ return field }) + r(field) -> ret(*|) L5 L5: 3 error: INIT: in: {} out: {} sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} + INIT: in: {a=I?} out: {a=I?} USE: in: {v=READ} out: {v=READ} ===================== == 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) -> INIT: in: {a=D, v=D} out: {a=D, v=D} w(v|) 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) -> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ} - w(field|) 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} + r(v) -> + w(field|) L8: - 3 INIT: in: {a=D, field=I, v=ID} out: {a=D, field=I, v=ID} + 3 error: - INIT: in: {} out: {} + INIT: in: {v=ID} out: {v=ID} sink: - INIT: in: {a=I?, field=I, v=I?} out: {a=I?, field=I, v=I?} USE: in: {} out: {} + INIT: in: {a=I?, v=ID} out: {a=I?, v=ID} USE: in: {v=READ} out: {v=READ} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions index 8d5d8633284..7d0840b0d0f 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions @@ -26,33 +26,33 @@ L0: call(foo(), foo) -> 2 jmp?(L2) jmp?(L3) - jmp(L4) USE: in: {} out: {} + jmp(L4) L2 [onException]: 3 v(e: Exception) INIT: in: {} out: {e=D} magic[FAKE_INITIALIZER](e: Exception) -> INIT: in: {e=D} out: {e=D} w(e|) INIT: in: {e=D} out: {e=ID} 4 mark({ val a = e }) INIT: in: {e=ID} out: {e=ID} - v(val a = e) INIT: in: {e=ID} out: {a=D, e=ID} USE: in: {e=READ} out: {e=READ} - r(e) -> INIT: in: {a=D, e=ID} out: {a=D, e=ID} USE: in: {} out: {e=READ} + v(val a = e) INIT: in: {e=ID} out: {a=D, e=ID} + r(e) -> INIT: in: {a=D, e=ID} out: {a=D, e=ID} w(a|) INIT: in: {a=D, e=ID} out: {a=ID, e=ID} - 3 jmp(L4) INIT: in: {e=ID} out: {e=ID} + 3 jmp(L4) INIT: in: {a=ID, e=ID} out: {a=ID, e=ID} L4 [afterCatches]: - 2 jmp(L5) INIT: in: {} out: {} + 2 jmp(L5) L3 [onExceptionToFinallyBlock]: L6 [start finally]: 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} + v(val a = 1) INIT: in: {a=ID, e=ID} out: {a=D, a=ID, e=ID} + r(1) -> INIT: in: {a=D, a=ID, e=ID} out: {a=D, a=ID, e=ID} + w(a|) INIT: in: {a=D, a=ID, e=ID} out: {a=ID, a=ID, e=ID} L7 [finish finally]: - 2 jmp(error) INIT: in: {} out: {} + 2 jmp(error) INIT: in: {a=ID, a=ID, e=ID} out: {a=ID, a=ID, e=ID} L5 [skipFinallyToErrorBlock]: L8 [copy of L3, onExceptionToFinallyBlock]: 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} - 2 merge(try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 }|, !) -> INIT: in: {} out: {} + v(val a = 1) + r(1) -> + w(a|) + 2 merge(try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 }|, !) -> mark("after") r("after") -> L1: @@ -60,5 +60,5 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {e=READ} out: {e=READ} =====================