Skip to content
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

Classic mode generates .cmx #336

Merged
merged 15 commits into from
Mar 2, 2022
Merged

Conversation

Keryan-dev
Copy link
Contributor

@Keryan-dev Keryan-dev commented Oct 15, 2021

From #203, relevant diff.

This improves #203 by generating .cmx for units compiled in classic mode, allowing the inlining to be done beyond the local unit.

Thanks to the work of @lthls, the cmx of both classic mode and simplify are compatible.

@Keryan-dev Keryan-dev changed the title Classic mode generate .cmx Classic mode generates .cmx Oct 15, 2021
@mshinwell mshinwell added the flambda2 Prerequisite for, or part of, flambda2 label Oct 15, 2021
Copy link
Contributor

@lukemaurer lukemaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing for me to check (only #203 changes files I own).

Gbury
Gbury previously requested changes Oct 18, 2021
Copy link
Contributor

@Gbury Gbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall (though I didn't look at the cmx handling changes). However, this PR conflicts with other re-factoring PR currently opened, and I suspect the rebase will be non trivial, so let's wait until the re-factoring PR are merged before merging this one ?

middle_end/flambda2/simplify/inlining/inlining_report.mli Outdated Show resolved Hide resolved
Copy link
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I haven't reviewed my own contributions too much

middle_end/flambda2/cmx/flambda_cmx.ml Outdated Show resolved Hide resolved
middle_end/flambda2/from_lambda/closure_conversion_aux.ml Outdated Show resolved Hide resolved
@Keryan-dev Keryan-dev force-pushed the classic-cmx branch 2 times, most recently from 5ceae03 to b682975 Compare February 25, 2022 13:31
Copy link
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've re-reviewed the PR. It's mostly fine, but I've left comments in a few places that we'll need to come back to at some point.

There are also a few small patches I'd like to make to the conversions between types and approximations, I'll approve when I've pushed them.

middle_end/flambda2/cmx/flambda_cmx.ml Show resolved Hide resolved
middle_end/flambda2/cmx/flambda_cmx.ml Show resolved Hide resolved
in
let used_closure_vars =
match used_closure_vars with
| Known used_closure_vars -> used_closure_vars
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove the Or_unknown wrapper around used_closure_vars now (but we can do it in a separate PR).

Name_occurrences.remove_continuation t.free_names cont
(* We don't remove the continuation from [t.continuation_applications]
here because we need this information of the module block to escape
its scope to build the .cmx in [Closure_conversion.close_program]. *)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't look like the cleanest way to solve this problem, but it works for now. We can come back with a better fix later.

middle_end/flambda2/types/flambda2_types.ml Outdated Show resolved Hide resolved
let alloc_mode =
match alloc_mode with
| Known am -> am
| Unknown -> Alloc_mode.Heap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit fishy, but I'm not sure Local allocations reachable from a symbol make sense anyway

middle_end/flambda2/types/env/typing_env.ml Outdated Show resolved Hide resolved
middle_end/flambda2/types/env/typing_env.ml Show resolved Hide resolved
@lthls lthls dismissed Gbury’s stale review March 2, 2022 13:40

Requested changes have been done

@mshinwell mshinwell merged commit bd757d2 into ocaml-flambda:main Mar 2, 2022

let prepare_cmx_from_approx ~approxs ~exported_offsets ~used_closure_vars
all_code =
if Flambda_features.opaque ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a || not (Flambda_features.classic_mode ()) to save some time when not in classic mode.

mshinwell pushed a commit that referenced this pull request May 20, 2022
* Conversions for approximations

* Refactor: Allow sharing of cmx loading outside Simplify

* Fix code loading

* Expose functions using approximations in Flambda_cmx

* make fmt

* Fix tests

* WIP cmx from classic mode

* Free names bugfix + cleanup

* Handle some edge-cases

* filter approximation of imported symbols

* retrict inlining to classic mode

* Comment and typo

* fix offsets exportation

* proper exported offsets

* Small cleanup in approx conversions

Co-authored-by: Vincent Laviron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants