@@ -253,10 +253,10 @@ let simplify_exits lam =
253
253
| Lletrec (bindings , body ) ->
254
254
let bindings =
255
255
List. map (fun ({ def = {kind; params; return; body = l ; attr; loc;
256
- mode; ret_mode; region } }
256
+ mode; ret_mode } }
257
257
as rb ) ->
258
258
let def =
259
- lfunction' ~kind ~params ~return ~mode ~ret_mode ~region
259
+ lfunction' ~kind ~params ~return ~mode ~ret_mode
260
260
~body: (simplif ~layout: None ~try_depth l) ~attr ~loc
261
261
in
262
262
{ rb with def })
@@ -587,12 +587,12 @@ let simplify_lets lam =
587
587
| _ -> no_opt ()
588
588
end
589
589
| Lfunction {kind= outer_kind; params; return= outer_return; body = l;
590
- attr= attr1; loc; ret_mode; mode; region = outer_region } ->
591
- begin match outer_kind, outer_region , simplif l with
590
+ attr= attr1; loc; ret_mode; mode} ->
591
+ begin match outer_kind, ret_mode , simplif l with
592
592
Curried {nlocal =0 } ,
593
- true ,
593
+ Alloc_heap ,
594
594
Lfunction {kind =Curried _ as kind ; params =params' ; return =return2 ;
595
- body; attr =attr2 ; loc; mode =inner_mode ; ret_mode; region }
595
+ body; attr =attr2 ; loc; mode =inner_mode ; ret_mode}
596
596
when optimize &&
597
597
attr1.may_fuse_arity && attr2.may_fuse_arity &&
598
598
List. length params + List. length params' < = Lambda. max_arity() ->
@@ -603,9 +603,9 @@ let simplify_lets lam =
603
603
type of the merged function taking [params @ params'] as
604
604
parameters is the type returned after applying [params']. *)
605
605
let return = return2 in
606
- lfunction ~kind ~params: (params @ params') ~return ~body ~attr: attr1 ~loc ~mode ~ret_mode ~region
607
- | kind , region , body ->
608
- lfunction ~kind ~params ~return: outer_return ~body ~attr: attr1 ~loc ~mode ~ret_mode ~region
606
+ lfunction ~kind ~params: (params @ params') ~return ~body ~attr: attr1 ~loc ~mode ~ret_mode
607
+ | kind , ret_mode , body ->
608
+ lfunction ~kind ~params ~return: outer_return ~body ~attr: attr1 ~loc ~mode ~ret_mode
609
609
end
610
610
| Llet (_str , _k , v , Lvar w , l2 ) when optimize ->
611
611
Hashtbl. add subst v (simplif (Lvar w));
@@ -802,7 +802,7 @@ and emit_tail_infos_lfunction _is_tail lfun =
802
802
function's body. *)
803
803
804
804
let split_default_wrapper ~id :fun_id ~kind ~params ~return ~body
805
- ~attr ~loc ~mode ~ret_mode ~ region : orig_region =
805
+ ~attr ~loc ~mode ~ret_mode =
806
806
let rec aux map add_region = function
807
807
(* When compiling [fun ?(x=expr) -> body], this is first translated
808
808
to:
@@ -882,28 +882,29 @@ let split_default_wrapper ~id:fun_id ~kind ~params ~return ~body
882
882
let inner_fun =
883
883
lfunction' ~kind: (Curried {nlocal= 0 })
884
884
~params: new_ids
885
- ~return ~body ~attr ~loc ~mode ~ret_mode ~region: true
885
+ ~return ~body ~attr ~loc ~mode ~ret_mode
886
886
in
887
887
(wrapper_body, { id = inner_id;
888
888
def = inner_fun })
889
889
in
890
890
try
891
891
(* TODO: enable this optimisation even in the presence of local returns *)
892
- begin match kind with
893
- | Curried {nlocal} when nlocal > 0 -> raise Exit
894
- | Tupled when not orig_region -> raise Exit
895
- | _ -> assert orig_region
892
+ begin match kind, ret_mode with
893
+ | Curried {nlocal} , _ when nlocal > 0 -> raise Exit
894
+ | Tupled , Alloc_local -> raise Exit
895
+ | _ , Alloc_heap -> ()
896
+ | _ , Alloc_local -> assert false
896
897
end ;
897
898
let body, inner = aux [] false body in
898
899
let attr = { default_stub_attribute with zero_alloc = attr.zero_alloc } in
899
900
[{ id = fun_id;
900
901
def = lfunction' ~kind ~params ~return ~body ~attr ~loc
901
- ~mode ~ret_mode ~region: true };
902
+ ~mode ~ret_mode };
902
903
inner]
903
904
with Exit ->
904
905
[{ id = fun_id;
905
906
def = lfunction' ~kind ~params ~return ~body ~attr ~loc
906
- ~mode ~ret_mode ~region: orig_region }]
907
+ ~mode ~ret_mode }]
907
908
908
909
(* Simplify local let-bound functions: if all occurrences are
909
910
fully-applied function calls in the same "tail scope", replace the
0 commit comments