[MLton] refs in ssa
Stephen Weeks
MLton@mlton.org
Tue, 9 Mar 2004 19:19:39 -0800
I agree with Matthew and would be very surprised to see a Ref_ref with
anything other than one argument. I see lots of places in the SSA
optimizer that assume it has exactly one argument. As my own sanity
check, I made the following patch to the latest version of MLton from
CVS.
----------------------------------------------------------------------
Index: mlton/ssa/analyze.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/ssa/analyze.fun,v
retrieving revision 1.23
diff -u -r1.23 analyze.fun
--- mlton/ssa/analyze.fun 20 Feb 2004 02:11:15 -0000 1.23
+++ mlton/ssa/analyze.fun 10 Mar 2004 03:10:49 -0000
@@ -197,11 +197,21 @@
ConApp {con, args} => conApp {con = con, args = values args}
| Const c => const c
| PrimApp {prim, targs, args, ...} =>
- primApp {prim = prim,
- targs = targs,
- args = values args,
- resultType = ty,
- resultVar = var}
+ let
+ val () =
+ case Prim.name prim of
+ Prim.Name.Ref_ref =>
+ if 1 = Vector.length args
+ then ()
+ else Error.bug "Ref_ref with wrong number of args"
+ | _ => ()
+ in
+ primApp {prim = prim,
+ targs = targs,
+ args = values args,
+ resultType = ty,
+ resultVar = var}
+ end
| Profile _ => unit
| Select {tuple, offset} =>
select {tuple = value tuple,
----------------------------------------------------------------------
I then rebuilt MLton, compiled all the regressions, benchmarks, and
MLton itself with -type-check true, and did not see any errors. This
means that after every SSA optimization pass, the SSA type checker
(which calls analyze) verified that the number of arguments to Ref_ref
is 1.
So, Luke, either you have modified the compiler in some way to change
the Ref_ref invariant, you are not running the compiler you think you
are, or you are not measuring what you think you are. My guess is the
latter -- perhaps the problem is that the Ref_ref in your code is a
variable, not the constructor Prim.Name.Ref_ref, which is not in
scope. Hence you are seeing the number of arguments for all
primitives, not Ref_ref.
If this is the case, and you compiled with MLton, you should have
gotten a redundant match warning. If you did not, let us know.
I would expect SML/NJ would report the warning as well.
Let us know if this is the problem.