Cmm dataflow analysis can't be used on the results of code generation
Cmm.Dataflow.analyzeCmmFwd works only on a
CmmGraph, not on a more general
But a more general analysis is needed in order to support the Asterius back end, which generates WebAssembly. This back end needs to take a
cmmTopCodeGen and convert it to structured control flow. The conversion requires a dominator analysis, which is most sensibly done using
Cmm.Dataflow (aka Hoopl).
This issue could be resolved by parameterizing the interface over the type of node found in a graph. To preserve backward compatibility, this could be done by introducing primed types similar to those found in
GHC.Cmm.Dataflow.Graph. For example,
type TransferFun' node f = Block node C C -> FactBase f -> FactBase f
The types (but not the names) of the analysis functions would also change:
analyzeCmmBwd, analyzeCmmFwd :: DataflowLattice f -> TransferFun' node f -> GenCmmGraph node -> FactBase f -> FactBase f
Could this change slow down compilation? Would any potential slowdown be appropriately mitigated using the SPECIALIZE pragma? Are there any CI tests for compile-time performance?