-
Notifications
You must be signed in to change notification settings - Fork 89
Transform tail-recursive function calls into calls to recursive continuations #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The module |
I'm not sure, but it doesn't seem that switch arms arguments are not accounted. In general, it seems a bit fragile to track it like that everywhere. Maybe doing it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, some changes needed
The detection of whether a function is completely tail-recursive is now done in lambda-to-flambda, which allows us to remove everything concerning the use of |
9bbf877
to
de29c69
Compare
Rebased for compatibility with the new Code_metadata refactor. |
07dce85
to
d0ec360
Compare
…l calls or not, it belonged to Downards_env rather than Closure_info
…y_toplevel_common
3a9894a
to
98d6366
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general ok.
let[@inline always] canon simple = | ||
Simple.without_coercion (TE.get_canonical_simple_exn tenv simple) | ||
in | ||
if Simple.equal (canon (Simple.var my_closure)) (canon (Apply.callee apply)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a comment for why this matter rather than doing that after simplify simple. Note that this would work after simplify_simple
In general I would prefer to try another method for is_purely_tail_call for a more robust method |
…rsive functions were not compiled to direct calls
…the pass to loopify, and warn if @unrolled attributes are used
Self tail-calls are identified at the very beginning of
simplify_apply_expr
and are transformed into a call to the recursive continuation corresponding to the function, which is always added. An optimisation insimplify_let_cont_expr
ensures that this recursive continuation is simplified if it is unused.