solang icon indicating copy to clipboard operation
solang copied to clipboard

Solang's intermediate representation should use SSA

Open LucasSte opened this issue 3 years ago • 2 comments

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::Instr need 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.

LucasSte avatar Jul 15 '22 19:07 LucasSte

Please, @seanyoung and @xermicus, join the discussion!

LucasSte avatar Jul 15 '22 19:07 LucasSte

I think this is closer than we think: in CFG we already have phi nodes. We just need to vars assign-once

seanyoung avatar Jul 16 '22 09:07 seanyoung