HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.CmmToAsm.Reg.Liveness

  • 9 types
  • 19 values
  • Packageghc-9.10.3
  • Exports28
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceLiveness.hs
typetype RegMap a = UniqFM Reg a
#

Map from some kind of register to a.

While we give the type for keys as Reg which is the common case sometimes we end up using VirtualReq or naked Uniques. See Note [UniqFM and the register allocator]

datadata InstrSR instr
#

The register allocator also wants to use SPILL/RELOAD meta instructions, so we'll keep those here.

Constructors

Instances3Functor, Outputable, Instruction
datadata Liveness
#

Liveness information. The regs which die are ones which are no longer live in the *next* instruction in this sequence. (NB. if the instruction is a jump, these registers might still be live at the jump target(s) - you have to check the liveness at the destination block to find out).

Constructors

valueslurpConflicts
  1. :: Instruction instr
  2. => LiveCmmDecl statics instr
  3. -> (Bag (UniqSet Reg), Bag (Reg, Reg))
#

Slurp out the list of register conflicts and reg-reg moves from this top level thing. Slurping of conflicts and moves is wrapped up together so we don't have to make two passes over the same code when we want to build the graph.

valueslurpReloadCoalesce
  1. :: Instruction instr
  2. => LiveCmmDecl statics instr
  3. -> Bag (Reg, Reg)
#

For spill/reloads

SPILL v1, slot1 ... RELOAD slot1, v2

If we can arrange that v1 and v2 are allocated to the same hreg it's more likely the spill/reload instrs can be cleaned and replaced by a nop reg-reg move.

valuepatchEraseLive
  1. :: Instruction instr
  2. => Reg -> Reg
  3. -> LiveCmmDecl statics instr
  4. -> LiveCmmDecl statics instr
#

Patch the registers in this code according to this register mapping. also erase reg -> reg moves when the reg is the same. also erase reg -> reg moves when the destination dies in this instr.

valuereverseBlocksInTops
  1. :: LiveCmmDecl statics instr
  2. -> LiveCmmDecl statics instr
#

If we've compute liveness info for this code already we have to reverse the SCCs in each top to get them back to the right order so we can do it again.