Draft: Implementing SSA transformation in NCG with Braun et al. algo.
This MR implements "(Pseudo-)SSA in NCG" #19453 using the Braun et al. (2013) algorith. It supersedes MR !5160 (closed)
Most of the implementation is located in SSA.hs in GHC.CmmToAsm.SSA
The rational and design is explained in the ticket and in the Note [ASM-SSA construction].
The code is not optimized and I'm sure that more performance can be gained. Also, the state is quite large, we might be able to reduce it and with it memory usage.
Some open TODOs:
- Document command line flags (
-fssa-transform
,-ddump-asm-ssa
,-ddump-asm-out-of-ssa
) - Test cases: I have not added any, yet
Open questions:
- I'm generating uniques directly for performance reasons with
mkUnique
- is this OK? -
isProductiveInstr
removes moves with identical src & dst - is this safe? - I'm completely relying on the CFG - will that be available on AARCH64 and what about PPC and SPARC?
I might have to promote real regs to SSA values for liveness analysis
Edited by Benjamin Maurer