In Hoopl, nodes, blocks, and graphs share an important new property: a shape. A thing’s shape tells us whether the thing is open or closed on entry and open or closed on exit. At an open point, control may implicitly “fall through;” at a closed point, control transfer must be explicit and to a named label. For example,

  • A shift-left instruction is open on entry (because control can fall into it from the preceding instruction), and open on exit (because control falls through to the next instruction).
  • An unconditional branch is open on entry, but closed on exit (because control cannot fall through to the next instruction).
  • A label is closed on entry (because in Hoopl we do not allow control to fall through into a branch target), but open on exit.
  • The shape of a function-call node is up to the client. If a call always returns to its inline successor, it could be open on entry and exit. But if a call could return in multiple ways– for example by returning normally or by raising an exception– then it has to be closed on exit. GHC uses calls of both shapes.

Ramsey, Norman, Joao Dias, and Simon Peyton Jones. “Hoopl: a modular, reusable library for dataflow analysis and transformation.” ACM Sigplan Notices. Vol. 45. No. 11. ACM, 2010.