HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.Cmm.Dataflow.Graph

  • 3 types
  • 1 class
  • 8 values
  • Packageghc-9.10.3
  • Exports12
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceGraph.hs
typetype Graph = Graph' Block
#

A control-flow graph, which may take any of four shapes (O/O, OC, CO, C/C). A graph open at the entry has a single, distinguished, anonymous entry point; if a graph is closed at the entry, its entry point(s) are supplied by a context.

datadata Graph' (block :: (Extensibility -> Extensibility -> Type) -> Extensibility -> Extensibility -> Type) (n :: Extensibility -> Extensibility -> Type) (e :: Extensibility) (x :: Extensibility) where
#

Graph' is abstracted over the block type, so that we can build graphs of annotated blocks for example (Compiler.Hoopl.Dataflow needs this).

Constructors

Instances1OutputableP
valuemapGraphBlocks
  1. :: forall (e1 :: Extensibility) (x1 :: Extensibility). block n e1 x1 -> block' n' e1 x1
  2. -> Graph' block n e x
  3. -> Graph' block' n' e x
#

Function mapGraphBlocks enables a change of representation of blocks, nodes, or both. It lifts a polymorphic block transform into a polymorphic graph transform. When the block representation stabilizes, a similar function should be provided for blocks.

valuerevPostorderFrom
  1. :: NonLocal block
  2. => LabelMap (block C C)
  3. -> Label
  4. -> [block C C]
#

Returns a list of blocks reachable from the provided Labels in the reverse postorder.

This is the most important traversal over this data structure. It drops unreachable code and puts blocks in an order that is good for solving forward dataflow problems quickly. The reverse order is good for solving backward dataflow problems quickly. The forward order is also reasonably good for emitting instructions, except that it will not usually exploit Forrest Baskett's trick of eliminating the unconditional branch from a loop. For that you would need a more serious analysis, probably based on dominators, to identify loop headers.

For forward analyses we want reverse postorder visitation, consider: A -> [B,C] B -> D C -> D Postorder: [D, C, B, A] (or [D, B, C, A]) Reverse postorder: [A, B, C, D] (or [A, C, B, D]) This matters for, e.g., forward analysis, because we want to analyze *both* B and C before we analyze D.