Skip to content

Commit

Permalink
Give my_closure accurate rec info (ocaml-flambda#1318)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemaurer authored May 4, 2023
1 parent cae4953 commit 26a962a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion middle_end/flambda2/simplify/simplify_set_of_closures.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,19 @@ let dacc_inside_function context ~outer_dacc ~params ~my_closure ~my_region
closure_bound_names_inside_function
| name ->
let name = Bound_name.name name in
let coercion =
(* The name at its binding site always has empty rec info by
definition. Since [my_closure] does have rec info (namely
[my_depth]), [my_closure] and the bound name are aliases only up to
a coercion. This is particularly important when lifting so that we
rewrite [my_closure] to the coerced symbol. *)
Coercion.change_depth ~from:Rec_info_expr.initial
~to_:(Rec_info_expr.var my_depth)
in
let aliased = Simple.with_coercion (Simple.name name) coercion in
DE.add_variable denv
(Bound_var.create my_closure NM.normal)
(T.alias_type_of K.value (Simple.name name)))
(T.alias_type_of K.value aliased))
in
let denv =
let my_region = Bound_var.create my_region Name_mode.normal in
Expand Down
4 changes: 2 additions & 2 deletions middle_end/flambda2/tests/mlexamples/tests11.flt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ and code rec loopify(never) size(69) newer_version_of(map_foo_4)
@`anon-fn[tests11.ml:15,2--70]`
with {
map_foo =
$camlTests11__map_foo_8 ~ depth my_depth -> succ my_depth
$camlTests11__map_foo_8 ~ depth 0 -> succ my_depth
}
in
cont k2 (`anon-fn[tests11.ml:15,2--70]`)
Expand All @@ -189,7 +189,7 @@ and code rec loopify(never) size(69) newer_version_of(map_foo_4)
@`anon-fn[tests11.ml:15,2--70]`
with {
map_foo =
$camlTests11__map_foo_8 ~ depth my_depth -> succ my_depth
$camlTests11__map_foo_8 ~ depth 0 -> succ my_depth
}
in
cont k2 (`anon-fn[tests11.ml:15,2--70]`))
Expand Down
4 changes: 2 additions & 2 deletions middle_end/flambda2/tests/mlexamples/tests11_out.fl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ and code rec loopify(never) size(69) newer_version_of(map_foo_4)
@`anon-fn[tests11.ml:15,2--70]`
with {
map_foo =
$camlTests11__map_foo_8 ~ depth my_depth -> succ my_depth
$camlTests11__map_foo_8 ~ depth 0 -> succ my_depth
}
in
cont k2 (`anon-fn[tests11.ml:15,2--70]`)
Expand All @@ -95,7 +95,7 @@ and code rec loopify(never) size(69) newer_version_of(map_foo_4)
@`anon-fn[tests11.ml:15,2--70]`
with {
map_foo =
$camlTests11__map_foo_8 ~ depth my_depth -> succ my_depth
$camlTests11__map_foo_8 ~ depth 0 -> succ my_depth
}
in
cont k2 (`anon-fn[tests11.ml:15,2--70]`))
Expand Down

0 comments on commit 26a962a

Please sign in to comment.