contifier bug

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Thu, 27 Sep 2001 12:21:36 -0400 (EDT)


> Two solutions:  
> 1. detect this case and mark the function as uncontifiable

I've gone with solution 1.  I think the solution is pretty simple; change
rule 5 in the definition of the graph G from
  {(k,g) | (f,g,k) \in N and R(f)}
to
  {(k,g) | (f,g,k) \in N and R(f) and (f,g,k) \not\in body(k)}
U {(Root,g) | (f,g,k) \in N and R(f) and (f,g,k) \in body(k)}

That is, when there is a non-tail call to g with continuation k in the
body of continuation k, then make Root a predecessor of g in the graph G;
this will guarantee that idom(g) = Root and Adom(g) = Unknown. 

This won't hurt us that much; things that were going to get contified at k
because they were tail-called from g will just get contified in g, because
g will still dominate them in G.

There are certainly cases where we won't get as much as we will with SSA:

(f,g1,k) in body of k
(f,g2,k) not in body of k
(g1,g2)

We want to contifiy both g1 and g2 at k;
But, under the new rule, we have edges
Root -> g1
Root -> k
k -> g2
g1 -> g2
which makes idom(g1) = idom(g2) = Root and Adom(g1) = Adom(g2) = Unknown.

Which is o.k., because there's no way to contify these functions under CPS
scoping rules.

Anyways, I put the modified contify.fun at
http://www.cs.cornell.edu/People/fluet/mlton/contify.tgz