[FIR] RHS assignment during equality comparison should invalidate DFA

If the right-hand side of an equality comparison contains an assignment
to the variable used in the left-hand side, then implications about the
equality comparison within data-flow analysis cannot be applied, as the
value of the variable will be different after the comparison.

^KT-55096 Fixed
This commit is contained in:
Brian Norman
2023-11-03 09:19:11 -05:00
committed by Space Team
parent 879f0eff71
commit b309786353
5 changed files with 34 additions and 11 deletions
@@ -109,6 +109,10 @@ abstract class LogicSystem(private val context: ConeInferenceContext) {
fun isSameValueIn(a: PersistentFlow, b: PersistentFlow, variable: RealVariable): Boolean =
a.assignmentIndex[variable] == b.assignmentIndex[variable]
fun isSameValueIn(a: PersistentFlow, b: MutableFlow, variable: RealVariable): Boolean {
return a.assignmentIndex[variable] == b.assignmentIndex[variable]
}
private fun MutableFlow.mergeAssignments(flows: Collection<PersistentFlow>) {
// If a variable was reassigned in one branch, it was reassigned at the join point.
val reassignedVariables = mutableMapOf<RealVariable, Int>()