[Git][ghc/ghc][wip/osa1/lfinfo] Documentation
Ömer Sinan Ağacan
gitlab at gitlab.haskell.org
Wed Apr 29 10:17:09 UTC 2020
Ömer Sinan Ağacan pushed to branch wip/osa1/lfinfo at Glasgow Haskell Compiler / GHC
Commits:
8049753a by Ömer Sinan Ağacan at 2020-04-29T13:16:57+03:00
Documentation
- - - - -
3 changed files:
- compiler/GHC/Iface/Make.hs
- compiler/GHC/Iface/UpdateIdInfos.hs
- compiler/GHC/StgToCmm/Types.hs
Changes:
=====================================
compiler/GHC/Iface/Make.hs
=====================================
@@ -103,7 +103,8 @@ mkPartialIface hsc_env mod_details
-- generator produced information.
--
-- CgInfos is not available when not generating code (-fno-code), or when not
--- generating interface pragmas (-fomit-interface-pragmas).
+-- generating interface pragmas (-fomit-interface-pragmas). See also
+-- Note [Conveying CAF-info and LFInfo between modules] in GHC.StgToCmm.Types.
mkFullIface :: HscEnv -> PartialModIface -> Maybe CgInfos -> IO ModIface
mkFullIface hsc_env partial_iface mb_cg_infos = do
let decls
=====================================
compiler/GHC/Iface/UpdateIdInfos.hs
=====================================
@@ -21,7 +21,11 @@ import GHC.Utils.Outputable
#include "HsVersions.h"
--- | Update CafInfos and LFInfos of all occurences (in rules, unfoldings, class instances)
+-- | Update CafInfos and LFInfos of all occurences (in rules, unfoldings, class
+-- instances).
+--
+-- See Note [Conveying CAF-info and LFInfo between modules] in
+-- GHC.StgToCmm.Types.
updateModDetailsIdInfos
:: DynFlags
-> CgInfos
=====================================
compiler/GHC/StgToCmm/Types.hs
=====================================
@@ -20,6 +20,50 @@ import GHC.Types.Name.Env
import GHC.Types.Name.Set
import GHC.Utils.Outputable
+{-
+Note [Conveying CAF-info and LFInfo between modules]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some information about an Id is generated in the code generator, and is not
+available earlier. Namely:
+
+* CAF info. Code motion in Cmm or earlier phases may move references around so
+ we compute information about which bits of code refer to which CAF late in the
+ Cmm pipeline.
+
+* LambdaFormInfo. This records the details of a closure representation,
+ including
+ - the final arity (for functions)
+ - whether it is a data constructor, and if so its tag
+
+Collectively we call this CgInfo (see GHC.StgToCmm.Types).
+
+It's very useful for importing modules to have this information. We can always
+make a conservative assumption, but that is bad: e.g.
+
+* For CAF info, if we know nothing we have to assume it is a CAF which bloats
+ the SRTs of the importing module.
+
+- For data constructors, we really like having well-tagged pointers. See #14677,
+ #16559, #15155, and wiki: commentary/rts/haskell-execution/pointer-tagging
+
+So we arrange to always serialise this information into the interface file. The
+moving parts are:
+
+* We record the CgInfo in the IdInfo of the Id.
+
+* GHC.Driver.Pipeline: the call to updateModDetailsIdInfos augments the
+ ModDetails constructed at the end of the Core pipeline, with with CgInfo
+ gleaned from the back end. The hard work is done in GHC.Iface.UpdateIdInfos.
+
+* For ModIface we generate the final ModIface with CgInfo in
+ GHC.Iface.Make.mkFullIface.
+
+* We don't absolutely guarantee to serialise the CgInfo: we won't if you have
+ -fomit-interface-pragmas or -fno-code; and we won't read it in if you have
+ -fignore-interface-pragmas. (We could revisit this decision.)
+-}
+
-- | Codegen-generated Id infos, to be passed to downstream via interfaces.
--
-- This stuff is for optimization purposes only, they're not compulsory.
@@ -29,6 +73,8 @@ import GHC.Utils.Outputable
-- `LFUnknown True` (which just says "it could be anything" and we do slow
-- entry).
--
+-- See also Note [Conveying CAF-info and LFInfo between modules] above.
+--
data CgInfos = CgInfos
{ cgNonCafs :: !NameSet
-- ^ Exported Non-CAFFY closures in the current module. Everything else is
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8049753a33c9bd0879b8c11af8ae315b7e1072ba
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8049753a33c9bd0879b8c11af8ae315b7e1072ba
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200429/ec474f4e/attachment-0001.html>
More information about the ghc-commits
mailing list