Skip to content

Fix to_cmm with complex arities #3982

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

Merged
merged 1 commit into from
May 14, 2025
Merged
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
14 changes: 8 additions & 6 deletions backend/cmm_helpers.ml
Original file line number Diff line number Diff line change
@@ -2988,12 +2988,12 @@ let maybe_reset_current_region ~dbg ~body_tail ~body_nontail old_region =
dbg () )

let apply_or_call_caml_apply result arity mut clos args pos mode dbg =
match args with
| [arg] ->
match arity with
| [_] ->
bind "fun" clos (fun clos ->
Cop
( Capply (Extended_machtype.to_machtype result, pos),
[get_field_codepointer mut clos 0 dbg; arg; clos],
(get_field_codepointer mut clos 0 dbg :: args) @ [clos],
dbg ))
| _ -> call_caml_apply result arity mut clos args pos mode dbg

@@ -4354,10 +4354,12 @@ let indirect_call ~dbg ty pos alloc_mode f args_type args =
might_split_call_caml_apply ty args_type Asttypes.Mutable f args pos
alloc_mode dbg

let indirect_full_call ~dbg ty pos alloc_mode f args_type = function
let indirect_full_call ~dbg ty pos alloc_mode f args_type args =
match args_type with
(* the single-argument case is already optimized by indirect_call *)
| [_] as args -> indirect_call ~dbg ty pos alloc_mode f args_type args
| args ->
| [_] -> indirect_call ~dbg ty pos alloc_mode f args_type args
| [] -> Misc.fatal_error "indirect_full_call: args_type was empty"
| _ :: _ :: _ ->
(* Use a variable to avoid duplicating the cmm code of the closure [f]. *)
let v = Backend_var.create_local "*closure*" in
let v' = Backend_var.With_provenance.create v in