Skip to content

Don't substitute into exclaves in simplif.ml #1448

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ocaml/lambda/simplif.ml
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ let simplify_lets lam =
| Lregion (l, _) ->
count bv l
| Lexclave l ->
count bv l
(* Not safe in general to move code into an exclave, so block
single-use optimizations by treating them the same as lambdas
and loops *)
count Ident.Map.empty l

and count_default bv sw = match sw.sw_failaction with
| None -> ()
Expand Down
19 changes: 19 additions & 0 deletions ocaml/testsuite/tests/typing-local/exclave.ml
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,22 @@ val bar : 'a -> string = <fun>
- : string = "Some of 5"
|}]

(* Ensure that Alias bindings are not substituted by Simplif (PR1448) *)
type 'a glob = Glob of ('a[@global])

let[@inline never] return_local a = [%local] (Glob a)

let f () =
let (Glob x) = return_local 1 in
[%exclave]
(let (_ : _) = return_local 99 in
assert (x = 1))
;;
f ();;
[%%expect{|
type 'a glob = Glob of global_ 'a
val return_local : 'a -> local_ 'a glob = <fun>
val f : unit -> local_ unit = <fun>
- : unit = ()
|}]