Closed yousifpatti closed 6 months ago
This is probably best implemented as a standard def-use anlayis (section 5.7 https://cs.au.dk/~amoeller/spa/spa.pdf) we can use the defining statement as the definition itself, and simply assign an SSA id to each variable defined at a given unique assign statement.
This means the datastructures are
Map[CfgPosition, Map[Variable, Set[LocalAssign]]]
for the set of definitions used by the statement (RHS) and for the set of defined variables Map[CfgPosition, Set[Variable]]
(LHS) Map[CfgPosition, Tuple[lhs -> Set[Variable], rhs -> Map[Variable, Set[LocalAssign]]]
Currently, the SSA directly mutates the Variables by adding the SSA sets which is undesirable. In order to move the Variables to be immutable, a new structure that contains the SSA Sets is needed and is proposed as follows:
Map[CfgNode/Stmt -> Tuple[reads -> Map[Variable, SSA-Set], writes -> KeyValuePair[Variable, SSA-Set]]
Also, a fixed point using a worklist solver is needed to ensure the SSA values are properly propagated and evaluated for loops