Skip to content

Generate ModDetails after code gen

Ömer Sinan Ağacan requested to merge osa1/ghc:refactor_tidyPgm into master

(See also: https://gitlab.haskell.org/ghc/ghc/wikis/CafInfo-rework)

This is a continuation of the previous work (f3cb8c7c) where we moved ModIface generation after code generation (after Cmm transformations are done, before final code generation). This allowed updating interface files with the code gen info. The information would then be available to importing modules.

However because it didn't update ModDetails (used by batch mode) the information was only available to importing modules in one-shot mode (an oversight).

With this patch we generate ModIface and ModDetails at the same place, allowing updating/generating both with the code gen info.

This is the final blocker for !1304 (merged). I've confirmed by rebasing !1304 (merged) on top of this branch that this works as expected and fixes the remaining issues with !1304 (merged).

This reverts some of the changes in f3cb8c7c as they're no longer needed. Specifically PartialModIface stuff is now gone; we keep the parts we need in ModGuts for ModDetails and ModIface generation in the new type CgModGuts. CgModGuts is basically ModGuts but lacking

  • mg_loc :: SrcSpan
  • mg_rules :: [CoreRule]
  • mg_binds :: CoreProgram
  • mg_foreign :: ForeignStubs
  • mg_foreign_files :: [(ForeignSrcLang, FilePath)]
  • mg_modBreaks :: Maybe ModBreaks
  • mg_inst_env :: InstEnv
  • mg_fam_inst_env :: FamInstEnv

mg_binds part is especially important to keep the residency low.

Note to reviewers

Important bits are:

  • HscTypes.hs: new type CgModGuts and new fields in CgGuts
  • TidyPgm.hs: tidyProgram now only returns CgGuts (previously CgGuts + ModDetails)
  • MkIface.hs: mkIface now returns ModIface + ModDetails (previously only ModIface)

Rest is just plumbing.

Edited by Ömer Sinan Ağacan

Merge request reports