CFA minor: retain initialization state while analyzing variable declaration
(cherry picked from commit c89f4db)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
436b0ec873
commit
f95dcad179
@@ -138,8 +138,7 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon
|
|||||||
enterInitState = getDefaultValueForInitializers(variable, instruction, blockScopeVariableInfo)
|
enterInitState = getDefaultValueForInitializers(variable, instruction, blockScopeVariableInfo)
|
||||||
}
|
}
|
||||||
if (!enterInitState.mayBeInitialized() || !enterInitState.isDeclared) {
|
if (!enterInitState.mayBeInitialized() || !enterInitState.isDeclared) {
|
||||||
val isInitialized = enterInitState.mayBeInitialized()
|
val variableDeclarationInfo = VariableControlFlowState.create(enterInitState.initState, isDeclared = true)
|
||||||
val variableDeclarationInfo = VariableControlFlowState.create(isInitialized, true)
|
|
||||||
exitInstructionData.put(variable, variableDeclarationInfo)
|
exitInstructionData.put(variable, variableDeclarationInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ L0:
|
|||||||
v(cond1: Boolean) INIT: in: {} out: {cond1=D}
|
v(cond1: Boolean) INIT: in: {} out: {cond1=D}
|
||||||
magic[FAKE_INITIALIZER](cond1: Boolean) -> <v0> INIT: in: {cond1=D} out: {cond1=D}
|
magic[FAKE_INITIALIZER](cond1: Boolean) -> <v0> INIT: in: {cond1=D} out: {cond1=D}
|
||||||
w(cond1|<v0>) INIT: in: {cond1=D} out: {cond1=ID}
|
w(cond1|<v0>) INIT: in: {cond1=D} out: {cond1=ID}
|
||||||
2 mark({ do { if (cond1) continue val cond2 = false } while (cond2) }) INIT: in: {cond1=ID} out: {cond1=ID} USE: in: {cond1=READ} out: {cond1=READ}
|
2 mark({ do { if (cond1) continue val cond2 = false } while (cond2) }) INIT: in: {cond1=ID} out: {cond1=ID} USE: in: {cond1=READ} out: {cond1=READ}
|
||||||
3 mark(do { if (cond1) continue val cond2 = false } while (cond2))
|
3 mark(do { if (cond1) continue val cond2 = false } while (cond2))
|
||||||
L2 [loop entry point]:
|
L2 [loop entry point]:
|
||||||
L4 [body entry point]:
|
L4 [body entry point]:
|
||||||
@@ -19,19 +19,19 @@ L4 [body entry point]:
|
|||||||
mark(if (cond1) continue)
|
mark(if (cond1) continue)
|
||||||
r(cond1) -> <v1>
|
r(cond1) -> <v1>
|
||||||
jf(L7|<v1>)
|
jf(L7|<v1>)
|
||||||
jmp(L6) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ}
|
jmp(L6) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ}
|
||||||
- jmp(L8)
|
- jmp(L8)
|
||||||
L7 [else branch]:
|
L7 [else branch]:
|
||||||
read (Unit) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?}
|
read (Unit) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?}
|
||||||
L8 ['if' expression result]:
|
L8 ['if' expression result]:
|
||||||
merge(if (cond1) continue|!<v2>) -> <v3>
|
merge(if (cond1) continue|!<v2>) -> <v3>
|
||||||
v(val cond2 = false) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=ID}
|
v(val cond2 = false) INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?D}
|
||||||
r(false) -> <v4> INIT: in: {cond1=ID, cond2=ID} out: {cond1=ID, cond2=ID}
|
r(false) -> <v4> INIT: in: {cond1=ID, cond2=I?D} out: {cond1=ID, cond2=I?D}
|
||||||
w(cond2|<v4>)
|
w(cond2|<v4>) INIT: in: {cond1=ID, cond2=I?D} out: {cond1=ID, cond2=ID}
|
||||||
L5 [body exit point]:
|
L5 [body exit point]:
|
||||||
L6 [condition entry point]:
|
L6 [condition entry point]:
|
||||||
r(cond2) -> <v5> INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?}
|
r(cond2) -> <v5> INIT: in: {cond1=ID, cond2=I?} out: {cond1=ID, cond2=I?}
|
||||||
jt(L2|<v5>) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ}
|
jt(L2|<v5>) USE: in: {cond1=READ, cond2=READ} out: {cond1=READ, cond2=READ}
|
||||||
L3 [loop exit point]:
|
L3 [loop exit point]:
|
||||||
read (Unit)
|
read (Unit)
|
||||||
L1:
|
L1:
|
||||||
@@ -39,5 +39,5 @@ L1:
|
|||||||
error:
|
error:
|
||||||
<ERROR> INIT: in: {} out: {}
|
<ERROR> INIT: in: {} out: {}
|
||||||
sink:
|
sink:
|
||||||
<SINK> INIT: in: {cond1=I?} out: {cond1=I?} USE: in: {} out: {}
|
<SINK> INIT: in: {cond1=I?} out: {cond1=I?} USE: in: {} out: {}
|
||||||
=====================
|
=====================
|
||||||
|
|||||||
@@ -11,21 +11,21 @@ L0:
|
|||||||
1 <START> INIT: in: {} out: {}
|
1 <START> INIT: in: {} out: {}
|
||||||
2 mark({ "before" do { var a = 2 } while (a > 0) "after" })
|
2 mark({ "before" do { var a = 2 } while (a > 0) "after" })
|
||||||
mark("before")
|
mark("before")
|
||||||
r("before") -> <v0> USE: in: {} out: {}
|
r("before") -> <v0> USE: in: {} out: {}
|
||||||
3 mark(do { var a = 2 } while (a > 0))
|
3 mark(do { var a = 2 } while (a > 0))
|
||||||
L2 [loop entry point]:
|
L2 [loop entry point]:
|
||||||
L4 [body entry point]:
|
L4 [body entry point]:
|
||||||
mark({ var a = 2 }) INIT: in: {a=I?} out: {a=I?}
|
mark({ var a = 2 }) INIT: in: {a=I?} out: {a=I?}
|
||||||
v(var a = 2) INIT: in: {a=I?} out: {a=ID}
|
v(var a = 2) INIT: in: {a=I?} out: {a=I?D}
|
||||||
r(2) -> <v1> INIT: in: {a=ID} out: {a=ID}
|
r(2) -> <v1> INIT: in: {a=I?D} out: {a=I?D}
|
||||||
w(a|<v1>)
|
w(a|<v1>) INIT: in: {a=I?D} out: {a=ID}
|
||||||
L5 [body exit point]:
|
L5 [body exit point]:
|
||||||
L6 [condition entry point]:
|
L6 [condition entry point]:
|
||||||
r(a) -> <v2>
|
r(a) -> <v2> INIT: in: {a=ID} out: {a=ID}
|
||||||
r(0) -> <v3>
|
r(0) -> <v3>
|
||||||
mark(a > 0)
|
mark(a > 0)
|
||||||
call(a > 0, compareTo|<v2>, <v3>) -> <v4>
|
call(a > 0, compareTo|<v2>, <v3>) -> <v4>
|
||||||
jt(L2|<v4>) USE: in: {a=READ} out: {a=READ}
|
jt(L2|<v4>) USE: in: {a=READ} out: {a=READ}
|
||||||
L3 [loop exit point]:
|
L3 [loop exit point]:
|
||||||
read (Unit)
|
read (Unit)
|
||||||
2 mark("after") INIT: in: {} out: {}
|
2 mark("after") INIT: in: {} out: {}
|
||||||
@@ -35,5 +35,5 @@ L1:
|
|||||||
error:
|
error:
|
||||||
<ERROR>
|
<ERROR>
|
||||||
sink:
|
sink:
|
||||||
<SINK> USE: in: {} out: {}
|
<SINK> USE: in: {} out: {}
|
||||||
=====================
|
=====================
|
||||||
Reference in New Issue
Block a user