Skip to content

Combine STG free variable traversals (#17978)

Alex D requested to merge nineonine/ghc:T17978 into master

Previously we would traverse the STG AST twice looking for free variables.

  • Once in annTopBindingsDeps which considers top level and imported ids free. Its output is used to put bindings in dependency order. The pass happens in STG pipeline.
  • Once in annTopBindingsFreeVars which only considers non-top level ids free. Its output is used by the code generator to compute offsets into closures. This happens in Cmm (CodeGen) pipeline. Now these two traversal operations are merged into one - FVs.depSortWithAnnotStgPgm. The pass happens right at the end of STG pipeline. Some type signatures had to be updated due to slight shifts of StgPass boundaries (for example, top-level CodeGen handler now directly works with CodeGen flavoured Stg AST instead of Vanilla).
Edited by Alex D

Merge request reports