Optimizer too smart....

Stephen Weeks sweeks@intertrust.com
Wed, 2 Feb 2000 13:48:47 -0800 (PST)


> So, I'm running into a psudo-bug. In that the optimizer (Cps.simplify) is
> doing too much work. In particular I pass datatypes to primitve C functions

This is a bad idea.  I strongly recommend that you write coercion
functions in the ML code to convert to/from types whose representation
is guaranteed.  The FFI section of the manual describes the allowed
types.

> and it's optimizing the representation in such a way incompatible with the
> old representation causing things to not type-check (i.e. I'm getting a type
> error not a segfault...)

I'm confused where you're getting the type error -- in the Cps
typechecker, in the C typechecker, or somewhere else?

> Is there some way to disable the representation optimization for a
> particular datatype? Or can you tell me what I need to do to just turn the
> whole thing off?

Many of the optimization passes on the Cps change datatype
declarations (useless, simplify-types, redundant,
remove-unused-constructors, ...).  Also, the backend does a bit more
representation optimization (representation.sig), which can't be
turned off.

Basically, I don't see any easy way to guarantee datatype
representations.