[MLton] nj-mlton on amd64 linux broken?

Matthew Fluet fluet at tti-c.org
Wed Sep 10 15:43:02 PDT 2008


On Wed, 10 Sep 2008, Vesa Karvonen wrote:
> I've been looking at committing the FP constant folding stuff.  One of
> the problems was that the code didn't compile with SML/NJ.  I've now
> changed the code to also compile with SML/NJ (and the optimization is
> disabled when MLton has been compiled with SML/NJ)

In the previous thread, I suggested looking at Real32.precision to 
determine if Real32 was really a 32-bit IEEE float or if it was bound to 
Real62 in the basis-stubs.  It occurs to me that you could also use 
MLton.isMLton (which is present via mlton-stubs even in a SML/NJ compile) 
to disable the optimization under SML/NJ.

> and I'd now like to make a sanity check that nothing broke.

Always a good thing!

> However, it seems that MLton built with SML/NJ on amd64 linux is broken.

MLton built with SML/NJ on amd64 has worked in the past.  It would be a 
good thing to get it working again.

> Here is what happens when I run bin/regression after make nj-mlton on 
> amd64 linux from unmodified SVN trunk:
>
> $ ./bin/regression
> MLton MLTONVERSION (built Wed Sep 10 22:44:30 2008 on caterpillar)
> flags = -type-check true
> testing 10
>        movq (gcState+0x18)(%rip),%r15
...
> assertion failure: amd64CodeGen.outputChunk
> compilation of 10 failed with -type-check true

An SML/NJ compiled MLton does all the Assert.assert checks (while a MLton 
compiled MLton does not), so the final assembly is being run through the 
amd64Validate module 
(<src>/mlton/codegen/amd64-codegen/amd64-validate.fun), which (in its x86 
incarnation) was meant to more informative than gas syntax errors during 
the initial development of the native codegen.  My guess is that %rip 
isn't being recognized as a valid register in this context --- indeed, it 
isn't a general purpose register, so there are lots of contexts in which 
it isn't valid, but it is o.k. as a base register.

Something like the following should help:

Index: mlton/codegen/amd64-codegen/amd64-validate.fun
===================================================================
--- mlton/codegen/amd64-codegen/amd64-validate.fun	(revision 6845)
+++ mlton/codegen/amd64-codegen/amd64-validate.fun	(working copy)
@@ -26,7 +26,9 @@
              else true

        fun validate_base {register}
-        = if not (validate {register = register}
+        = if not (eq (register, rip))
+             andalso
+             not (validate {register = register}
                    andalso
                    List.contains(baseRegisters,
                                  register,



More information about the MLton mailing list