[MLton] question on closure-convert.fun
Matthew Fluet
fluet@cs.cornell.edu
Wed, 22 Jun 2005 06:41:37 -0400 (EDT)
> > These extraneous assignments will be killed off by the removeUnused
> > pass if they are truly unused in the rest of the program.
>
> If you add the assignments as global statements in the argument to
> Ssa.shrinkFucntion, won't they just not appear in the output
> (i.e. "blocks")?
No, you misunderstand what I was proposing. Instead of:
Ssa.Exp.Tuple vs =>
if Vector.equals(vars, vs, Var.equals)
then ()
else Error.bug "shrinker didn't simplify right"
have
Ssa.Exp.Tuple vs =>
if Vector.length vars = Vector.length vs
then vs
else Error.bug "shrinker didn't simplify right"
and
val rebinds =
Vector.keepAllMapi
(vs, fn (i, v) =>
if Var.equals (v, Vector.sub (vars, i))
then NONE
else SOME (Ssa.Statement.T
{exp = Ssa.Exp.Var v,
ty = Vector.sub (tys, i),
var = SOME (Vector.sub (vars, i))}))
That is, if we see that the shrinker determined that a variable was equal
to another variable, simply rebind the eliminated variable.