[MLton] bug in ssaToRssa

Stephen Weeks MLton@mlton.org
Tue, 28 Sep 2004 17:32:14 -0700


> I just checked in a revised remove-unused2.fun.  It's not completely
> tested, and I'm not quite happy with it yet.  But, it seems to tickle a
> bug in the ssaToRssa pass.  Trying to compile mlyacc.mlb with the
...
> invalid transfer: L_16 (Cast (Cast (x_1851: Pointers (pt_149, pt_148, pt_147),
> 				    Pointers (pt_149, pt_148, pt_147)),
> 			      Pointers (pt_147)))
...
> Rssa type error
...
> At the very least, all of the SSA2 passes pass the type-checker, so either
> there is a bug in ssaToRssa or there is an invariant that isn't being
> checked by the type-checker.

I have checked in a fix.

The type checker in Ssa2 explicitly allows a case destination to take
zero arguments, but conversion to Rssa was not always handling this.
The new removeUnused pass eliminated an unused argument from a case
destination and tickled the bug, which (correctly) showed up as a type
error in Rssa.  The fix involved code in the Ssa2 to Rssa conversion
to keep track of the arity of case destinations.

It is worth considering whether we really want to allow zero-argument
case destinations in Ssa2, which does require special case code in
several places.  On the plus side, it does allow unused variables to
be removed.