MLton 20210117

# CommonBlock

CommonBlock is an optimization pass for the SSA IntermediateLanguage, invoked from SSASimplify.

## Description

It eliminates equivalent blocks in a SSA function. The equivalence criteria requires blocks to have no arguments or statements and transfer via Raise, Return, or Goto of a single global variable.

## Implementation

- common-block.fun

## Details and Notes

- Rewrites

      L_X ()
        raise (global_Y)

  to

      L_X ()
        L_Y' ()

  and adds

      L_Y' ()
        raise (global_Y)

  to the SSA function.

- Rewrites

      L_X ()
        return (global_Y)

  to

      L_X ()
        L_Y' ()

  and adds

      L_Y' ()
        return (global_Y)

  to the SSA function.

- Rewrites

      L_X ()
        L_Z (global_Y)

  to

      L_X ()
        L_Y' ()

  and adds

      L_Y' ()
        L_Z (global_Y)

  to the SSA function.

The Shrink pass rewrites all uses of L_X to L_Y' and drops L_X.

For example, all uncaught Overflow exceptions in a SSA function share the same raising block.