Matthew Fluet
Wed, 8 Aug 2001 12:16:18 -0700 (PDT)

> Matthew, commonBlock is causing regression failures (presumably due to scoping)
> on array4 and cases.

I'm checking in a fix to that right now.

Here's the problem:

fun f ()
  = let
       fun loop (x) = ...
       fun doit_1 () = loop (global_1)
       fun doit_2 () = loop (global_1)
    fun loop (x)
      = let
          fun g () = loop (global_1)
          fun h () = loop (global_1)

There are four blocks that have identical bodies.  So, I want to replace
bodies of the form  loop (global_1)  with  L ()  and insert the
declaration  fun L () = loop (global_1).

The question is where do I insert that declaration?  For g and h, it needs
to go as the first declaration inside loop.  For doit_1 and doit_2 it
needs to go as the first declaration after loop.  The increasingly
inelegant solution is to maintain two sets of common block declarations
for each jump label -- those that go inside and those that go after.
Ugh... Wouldn't it be great if there were some IL where I could just add
new blocks to a function without needing to maintain restrictive scoping
requirements. ;-)