Skip to content

Annotate Cmm.fundecl with only_kept_for_zero_alloc#2813

Draft
mshinwell wants to merge 1 commit intooxcaml:mainfrom
mshinwell:flambda2-propagate-never-delete
Draft

Annotate Cmm.fundecl with only_kept_for_zero_alloc#2813
mshinwell wants to merge 1 commit intooxcaml:mainfrom
mshinwell:flambda2-propagate-never-delete

Conversation

@mshinwell
Copy link
Copy Markdown
Collaborator

@mshinwell mshinwell commented Jul 18, 2024

It should be the case that the flag is set iff:

  • the function is unreachable; and
  • the function is annotated with a zero-alloc Check attribute; and
  • flambda2 would have deleted the function save for the presence of such attribute.

WIP for @gretay-js

@mshinwell mshinwell added flambda2 Prerequisite for, or part of, flambda2 backend labels Jul 18, 2024
@mshinwell mshinwell marked this pull request as draft July 18, 2024 10:39
@mshinwell mshinwell added the zero alloc zero-alloc check label Jul 18, 2024
@mshinwell
Copy link
Copy Markdown
Collaborator Author

Small example:

% cat rec.ml
let[@zero_alloc] rec f x = 1 + g (x * 2)
and[@zero_alloc] g x = 2 + f (x - 3)

let bar x = x + 1
% cat rec.mli
val bar : int -> int

@mshinwell
Copy link
Copy Markdown
Collaborator Author

(If we want to go ahead with something like this, @Gbury should look at the dataflow-related part of this PR to make sure it matches the specification above.)

@Gbury
Copy link
Copy Markdown
Contributor

Gbury commented Aug 26, 2024

As said some time ago on slack: the current code seems okay (for the data flow part at least), but it's not great to run the whole data_flow analysis twice. Instead I'd prefer if only the reachability analysis part of the flow analysis was run twice.

@mshinwell
Copy link
Copy Markdown
Collaborator Author

@gretay-js what should we do with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend flambda2 Prerequisite for, or part of, flambda2 zero alloc zero-alloc check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants