Transform tail-recursive function calls into calls to recursive continuations#836
Transform tail-recursive function calls into calls to recursive continuations#836Ekdohibs wants to merge 30 commits intooxcaml:mainfrom
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 |
chambart
left a comment
There was a problem hiding this comment.
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
| 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.
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_exprand are transformed into a call to the recursive continuation corresponding to the function, which is always added. An optimisation insimplify_let_cont_exprensures that this recursive continuation is simplified if it is unused.