remove-unused

Matthew Fluet fluet@CS.Cornell.EDU
Fri, 26 Oct 2001 14:30:17 -0400 (EDT)


> I am confused by the code in remove-unused.  I don't understand what
> "doesTerminate" means.  You sometimes seem to use it to mean "must
> terminate" and other times to mean "may terminate".  Which is it?

You mean it can't be both? ;)

> As evidence, I point to the fact that if a function contains a Return
> statement, it is marked as "doesTerminate".  This corresponds to "may
> terminate".  

I guess I want it to be "may terminate", to match with "may fail".  

> But, in translating calls you eliminate a call if it does not side
> effect, does not raise, and doesTerminate.  To me, this requires
> the "must terminate" interpretation, and therefore seems wrong.

Yes, this would require "must terminate."  

> Clarification?

The elimination of a Call is wrong the way the terminate flag is computed. 
The rewrite of the return cont and handler is o.k. with the terminate flag
interpreted as may terminate.  (i.e., we can drop the existing
continuation when the callee cannot terminate, and either replace it with
a bug continuation (if we need to preserve the handler, or if type
checking prevents us from making a non-tail call to non-terminating,
non-failing function (i.e., an infinite loop)) or a tail call (if types
match up)).


We could compute a may loop condition and use it to drop calls to
functions that don't raise or side-effect or loop.  Will it buy much?  I
saw one instance of where we dropped a call in life, but it's wrong
because the called function has loops (on lists, which must be finite, but
that's not going to come out of a simple analysis).  I can't imagine it's
that prevelant.  So, I'll correct removeUnused as described above and add
the may loop low on my todo.