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

to_cmm: do not fail on recinfo continuation parameters #2627

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
rename
  • Loading branch information
Ekdohibs committed May 27, 2024
commit 4136c507755f34745dc1f0bd0de7f7491d5ae857
2 changes: 1 addition & 1 deletion middle_end/flambda2/to_cmm/to_cmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ let unit0 ~offsets ~all_code ~reachable_names flambda_unit =
C.create_ccatch ~rec_flag:false ~body
~handlers:
[ C.handler ~dbg return_cont
(C.actual_params return_cont_params)
(C.remove_skipped_params return_cont_params)
unit_value false ]
in
let body =
Expand Down
9 changes: 6 additions & 3 deletions middle_end/flambda2/to_cmm/to_cmm_expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ let translate_jump_to_continuation ~dbg_with_inlined:dbg env res apply types
let cont = Env.get_cmm_continuation env exn_handler in
[Cmm.Push cont]
in
let args = C.actual_args args types in
let args = C.remove_skipped_args args types in
let args, free_vars, env, res, _ = C.simple_list ~dbg env res args in
let wrap, _, res = Env.flush_delayed_lets ~mode:Branching_point env res in
let cmm, free_vars = wrap (C.cexit cont args trap_actions) free_vars in
Expand Down Expand Up @@ -646,7 +646,9 @@ and let_cont_not_inlined env res k handler body =
in
( C.create_ccatch ~rec_flag:false ~body
~handlers:
[C.handler ~dbg catch_id (C.actual_params vars) handler is_cold],
[ C.handler ~dbg catch_id
(C.remove_skipped_params vars)
handler is_cold ],
free_vars,
res )
in
Expand Down Expand Up @@ -775,7 +777,8 @@ and let_cont_rec env res invariant_params conts body =
(C.remove_vars_with_machtype free_vars_of_handler vars)
in
let id = Env.get_cmm_continuation env k in
( C.handler ~dbg id (C.actual_params vars) handler false :: handlers,
( C.handler ~dbg id (C.remove_skipped_params vars) handler false
:: handlers,
free_vars ))
conts_to_handlers ([], free_vars_of_body)
in
Expand Down
11 changes: 6 additions & 5 deletions middle_end/flambda2/to_cmm/to_cmm_shared.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ open! Cmm_helpers
open! Cmm_builtins
module Ece = Effects_and_coeffects

let actual_params params_with_types =
let remove_skipped_params params_with_types =
List.filter_map
(fun (v, param_type) ->
match (param_type : Cmm.machtype To_cmm_env.param_type) with
| Skip_param -> None
| Param machtype -> Some (v, machtype))
params_with_types

let rec actual_args args param_types =
let rec remove_skipped_args args param_types =
match args, (param_types : _ To_cmm_env.param_type list) with
| [], [] -> []
| _ :: r, Skip_param :: r' -> actual_args r r'
| arg :: r, Param _ :: r' -> arg :: actual_args r r'
| _ :: r, Skip_param :: r' -> remove_skipped_args r r'
| arg :: r, Param _ :: r' -> arg :: remove_skipped_args r r'
| _ :: _, [] | [], _ :: _ ->
Misc.fatal_errorf "Mismatched list sizes in To_cmm_shared.actual_args"
Misc.fatal_errorf
"Mismatched list sizes in To_cmm_shared.remove_skipped_args"

let remove_var_with_provenance free_vars var =
let v = Backend_var.With_provenance.var var in
Expand Down
4 changes: 2 additions & 2 deletions middle_end/flambda2/to_cmm/to_cmm_shared.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
this module, unlike the ones in [Cmm_helpers], depend on Flambda 2 data
types. *)

val actual_params :
val remove_skipped_params :
(Backend_var.With_provenance.t * Cmm.machtype To_cmm_env.param_type) list ->
(Backend_var.With_provenance.t * Cmm.machtype) list

val actual_args : 'a list -> _ To_cmm_env.param_type list -> 'a list
val remove_skipped_args : 'a list -> _ To_cmm_env.param_type list -> 'a list

val remove_var_with_provenance :
To_cmm_env.free_vars -> Backend_var.With_provenance.t -> To_cmm_env.free_vars
Expand Down
Loading