solang
solang copied to clipboard
Solang's intermediate representation should use SSA
Solang's intermediate representation does not use a static single assignment (SSA) form. This has introduced some ugliness in our code base. For instance, we have two three different implementations of reaching definitions: one for strength reduce, another for the vector to slice pass and a third one for all other optimization passes.
Advantages
- SSA renders reaching definitions unnecessary and may carry enough information for all optimization passes.
- This eliminates some tricks in our code to bypass the absence of SSA, like this one.
- SSA streamlines the implementation of liveness analysis, allowing us to remove our impromptu unused variable removal code.
- The CFG needs only small changes to support SSA.
Caveats
CFG::Instrneed to be refactored to accommodate Phi instructions.
Challenges
- We need to refactor our VarTable dirty tracker.
- This will imply changes in emit.
- All existing optimization passes need to be adapted.
Please, @seanyoung and @xermicus, join the discussion!
I think this is closer than we think: in CFG we already have phi nodes. We just need to vars assign-once