Skip to content

Commit 263a9d7

Browse files
committed
Dissect_letrec generates a Ltail
1 parent 8a80f7f commit 263a9d7

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

middle_end/flambda2/from_lambda/dissect_letrec.ml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ let rec prepare_letrec (recursive_set : Ident.Set.t)
537537
| Lregion (body, _) ->
538538
let letrec = prepare_letrec recursive_set current_let body letrec in
539539
{ letrec with needs_region = true }
540+
| Ltail _body ->
541+
(* No tail expected here *)
542+
assert false
540543
[@@ocaml.warning "-fragile-match"]
541544

542545
let dissect_letrec ~bindings ~body =
@@ -573,18 +576,10 @@ let dissect_letrec ~bindings ~body =
573576
id, Lprim (Pccall desc, [size], Loc_unknown))
574577
letrec.blocks
575578
in
576-
let real_body = body in
577-
let bound_ids_freshening =
578-
List.map (fun (bound_id, _) -> bound_id, Ident.rename bound_id) bindings
579-
|> Ident.Map.of_list
580-
in
581-
let cont = next_raise_count () in
582579
let body =
583580
if not letrec.needs_region
584581
then body
585-
else
586-
let args = List.map (fun (bound_id, _) -> Lvar bound_id) bindings in
587-
Lstaticraise (cont, args)
582+
else Ltail body
588583
in
589584
let effects_then_body = lsequence (letrec.effects, body) in
590585
let functions =
@@ -616,18 +611,7 @@ let dissect_letrec ~bindings ~body =
616611
with_preallocations letrec.consts
617612
in
618613
let substituted = Lambda.rename letrec.substitution with_constants in
619-
let body_layout = Lambda.layout_top in
620-
if not letrec.needs_region
621-
then substituted
622-
else
623-
Lstaticcatch
624-
( Lregion (Lambda.rename bound_ids_freshening substituted, body_layout),
625-
( cont,
626-
List.map
627-
(fun (bound_id, _) -> bound_id, Lambda.layout_letrec)
628-
bindings ),
629-
real_body,
630-
body_layout )
614+
substituted
631615

632616
type dissected =
633617
| Dissected of Lambda.lambda

0 commit comments

Comments
 (0)