shrinker checked in

Stephen Weeks MLton@sourcelight.com
Tue, 13 Nov 2001 23:05:51 -0800


Finally, it's there.  I'm running benchmarks tonight to compare the
CPS and SSA optimizers and will report on them tomorrow.  

Here's the log.

--------------------------------------------------------------------------------
The SSA shrinker now works.  There are also a lot of other changes to the SSA IL
and corresponding changes to the SSA optimizations and backend.  Here's an
overview.

* There is a new switch, -optimize-ssa {true|false}, which determines whether
  the SSA or CPS optimizer is used.  They are no longer run in sequence.

* Implement handlers has been moved from the SSA simplify pipeline to backend,
  and also implements other invariants that the backend needs.

* SSA IL changes
  - changed Raise transfer back to taking Var.t vector instead of Var.t.
    This simplified some of the optimizations and made it easier since it
    can often be treated exactly as return.
  - Change the return type of functions from Type.t vector to
    Type.t vector option.  NONE indicates that a function does not return.
  - Added mayRaise: bool to functions to record whether or not a function may
    raise.
  - Changed returns to the following datatype

	    datatype t =
	       Dead
	     | HandleOnly
	     | NonTail of {cont: Label.t, handler: Handler.t}
	     | Tail

    These correspond to 6 of the possible 9 combinations of continuation and
    handler each being one of {None, Caller, Some l}.  None means that it
    doesn't matter what the continuation (handler) is since the caller never
    returns (raises).  Caller means to keep the continuation (handler) the same
    as in the caller.  Some l means a nontail call in the case of continuations
    and an installed handler in the case of handlers.

    3 of the 9 possibilities are disallowed, and the correspondence is as below.

	Cont	Handler		equivalent
	------	-------		---------------------------------------
	None	None		Dead
	None	Caller		HandleOnly
	None 	Some h		*disallowed*
	Caller	None		*disallowed*
	Caller	Caller		Tail
	Caller	Some h		*disallowed*
	Some l	None		Nontail {cont = l, handler = None}
	Some l	Caller		Nontail {cont = l, handler = Caller}
	Some l	Some h		Nontail {cont = l, handler = Handle l}

    We could have allowed the (None, Some h) and (Caller, Some h) cases, and
    put some code in the backend to generate stubs, since if there is a handler
    there must be some continuation.  But I decided it was easier to just rule
    them out, essentially meaning that remove-unused, or any other optimization
    pass, needs to make stubs itself.

The matchup between returns and what is now expressed in functions types
(mayRaise and mayReturn) is checked in the type checker.

The checked in compiler passes all regressions, but is not able to self-compile,
or even be compiled, at least with 500m.  The bloat due to having all of the CPS
and SSA optimization passes is too much.  Hopefully we will soon decide to pitch
the CPS and will be able to self-compile again.