GHC.Cmm.Info.Build

ghc-9.14.0.20251028: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Cmm.Info.Build

Synopsis

- type CAFSet = Set CAFfyLabel
- type CAFEnv = LabelMap CAFSet
- cafAnal :: Platform -> LabelSet -> CLabel -> CmmGraph -> CAFEnv
- cafAnalData :: Platform -> CmmStatics -> CAFSet
- doSRTs :: CmmConfig -> ModuleSRTInfo -> DUniqSupply -> [(CAFEnv, [CmmDecl])] -> [(CAFSet, CmmDataDecl)] -> IO (ModuleSRTInfo, DUniqSupply, [CmmDeclSRTs])
- data ModuleSRTInfo = ModuleSRTInfo {
  - thisModule :: Module
  - dedupSRTs :: Map (Set SRTEntry) SRTEntry
  - flatSRTs :: Map SRTEntry (Set SRTEntry)
  - moduleSRTMap :: SRTMap
  }
- emptySRT :: Module -> ModuleSRTInfo
- type SRTMap = Map CAFfyLabel (Maybe SRTEntry)
- srtMapNonCAFs :: SRTMap -> NonCaffySet

# Documentation

type CAFSet = Set CAFfyLabel Source #

type CAFEnv = LabelMap CAFSet Source #

cafAnal Source #

Arguments

:: Platform |
-> LabelSet | The blocks representing continuations, ie. those that will get RET info tables. These labels will get their own SRTs, so we don't aggregate CAFs from references to these labels, we just use the label.
-> CLabel | The top label of the proc
-> CmmGraph |
-> CAFEnv |

For each code block: - collect the references reachable from this code block to FUN, THUNK or RET labels for which `hasCAF == True`

This gives us a `CAFEnv`: a mapping from code block to sets of labels

cafAnalData :: Platform -> CmmStatics -> CAFSet Source #

Collect possible CAFfy references from a `CmmData` decl.

doSRTs Source #

Arguments

:: CmmConfig |
-> ModuleSRTInfo |
-> DUniqSupply |
-> [(CAFEnv, [CmmDecl])] | `CAFEnv`s and `CmmDecl`s for code blocks
-> [(CAFSet, CmmDataDecl)] | static data decls and their `CAFSet`s
-> IO (ModuleSRTInfo, DUniqSupply, [CmmDeclSRTs]) |

Attach SRTs to all info tables in the `CmmDecl`s, and add SRT declarations to the `ModuleSRTInfo`.

data ModuleSRTInfo Source #

Constructors

ModuleSRTInfo |
Fields thisModule :: Module Current module being compiled. Required for calling labelDynamic. dedupSRTs :: Map (Set SRTEntry) SRTEntry previous SRTs we've emitted, so we can de-duplicate. Used to implement the [Common] optimisation. flatSRTs :: Map SRTEntry (Set SRTEntry) The reverse mapping, so that we can remove redundant entries. e.g. if we have an SRT [a,b,c], and we know that b points to [c,d], we can omit c and emit [a,b]. Used to implement the [Filter] optimisation. moduleSRTMap :: SRTMap

#### Instances

Instances details

OutputableP env CLabel => OutputableP env ModuleSRTInfo Source # |
Instance details Defined in GHC.Cmm.Info.Build Methods pdoc :: env -> ModuleSRTInfo -> SDoc Source #

emptySRT :: Module -> ModuleSRTInfo Source #

type SRTMap = Map CAFfyLabel (Maybe SRTEntry) Source #

Maps labels from `cafAnal` to the final CLabel that will appear in the SRT. - closures with singleton SRTs resolve to their single entry - closures with larger SRTs map to the label for that SRT - CAFs must not map to anything! - if a labels maps to Nothing, we found that this label's SRT is empty, so we don't need to refer to it from other SRTs.

srtMapNonCAFs :: SRTMap -> NonCaffySet Source #

Given `SRTMap` of a module, returns the set of non-CAFFY names in the module. Any `Name`s not in the set are CAFFY.