contifier bug
Matthew Fluet
fluet@CS.Cornell.EDU
Thu, 27 Sep 2001 11:30:48 -0400 (EDT)
> I am working on implementing MLton.Exn.history, and in doing so, tickled another
> contifier bug, where the contifier produces a program in which a continuation is
> called before its definition (yeah, yeah, SSA will be there RSN).
It's inner/outer again. Blech...
fun main_0 ()
= let
...
fun x_6 (env_14)
= let
...
fun L_171 (env_13) = x_6 (x_258 (env_3))
...
in
...
end
fun x_188 (env_10) = x_6 (x_258 (env_3))
...
in
...
end
The transformation places the contified x_258 immediately after the
declaration of x_6, out of the scope of the transformed L_171 body.
Two solutions:
1. detect this case and mark the function as uncontifiable
2. duplicate the contified function put one inside and one outside and
rely on the shrinker to kill the unnecessary versions. But, as we all
know, "contification does not duplicate code -- it only moves code from
one place to another, exposing control-flow information" [FS01].
Furthermore, note that in the above case, we can't kill either of the
versions, so they will both stick around. In the above case, x_258 is a
trivial function, so the duplication of code doesn't exceed what the
inliner would probably do. But, nothing prevents x_258 from being
monstrous.
I'm leaning towards 1, especially since this problem will go away RSN with
SSA.