Lifting of statically closed functions in Lambda_to_flambda#511
Lifting of statically closed functions in Lambda_to_flambda#511Keryan-dev wants to merge 1 commit intoocaml-flambda:flambda2.0-stablefrom
Conversation
| |> Closure_id.Lmap.mapi (fun closure_id _ -> | ||
| Symbol.create (Compilation_unit.get_current_exn ()) | ||
| (Linkage_name.create | ||
| (Variable.unique_name (Closure_id.unwrap closure_id)))) |
There was a problem hiding this comment.
You should probably use the same code as Simplify_set_of_closures.simplify_and_lift_set_of_closures, which would be Linkage_name.create (Closure_id.to_string closure_id) (I think you can skip the extra Closure_id.rename here).
|
We already discussed this, but here is the main issue with this PR:
This PR implements solution 3. Apart from a small comment the code looks correct. |
Note that in this patch the code will still fetch recursive functions through its closure, there is no direct reference to set of closures symbols, I think, so what you describe should not happen (at least, no more than before, as it was the case in But yes, in fine we would remove |
|
I thought that adding a substitution to the symbol would automatically transform the recursive calls too. Is the substitution only used for the code outside the function ? I think it would be correct to also use it inside the function. |
|
The body of functions is processed before the symbols are added to the environment here. I'm not sure that adding them before would clear the |
|
Being done in the Flambda backend repo. |
This converts sets of closures to top-level symbols when possible.
This can be improved further by removing the closure entirely, and referring recursive functions by their symbols directly in the code. It would require a more involved patch as the code of relevant functions would change, and symbols would need to be declared in topological order.