File tree Expand file tree Collapse file tree 8 files changed +13
-9
lines changed Expand file tree Collapse file tree 8 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -566,7 +566,7 @@ let emit_named_text_section func_name =
566
566
(* Name of current function *)
567
567
let function_name = ref ""
568
568
(* Entry point for tail recursive calls *)
569
- let tailrec_entry_point = ref 0
569
+ let tailrec_entry_point = ref None
570
570
571
571
(* Emit tracing probes *)
572
572
@@ -722,7 +722,9 @@ let emit_instr fallthrough i =
722
722
| Lop(Itailcall_imm { func; label_after; }) ->
723
723
begin
724
724
if func = !function_name then
725
- I.jmp (label !tailrec_entry_point)
725
+ match !tailrec_entry_point with
726
+ | None -> Misc.fatal_error "jump to missing tailrec entry point"
727
+ | Some tailrec_entry_point -> I.jmp (label tailrec_entry_point)
726
728
else begin
727
729
output_epilogue begin fun () ->
728
730
add_used_symbol func;
Original file line number Diff line number Diff line change @@ -138,7 +138,9 @@ let compile_fundecl ~ppf_dump fd_cmm =
138
138
if ! use_ocamlcfg then begin
139
139
let cfg = Ocamlcfg.Cfg_with_layout. of_linear fd ~preserve_orig_labels: true in
140
140
let fun_body = Ocamlcfg.Cfg_with_layout. to_linear cfg in
141
- { fd with Linear. fun_body; }
141
+ let fun_tailrec_entry_point_label =
142
+ Ocamlcfg.Cfg. fun_tailrec_entry_point_label (Ocamlcfg.Cfg_with_layout. cfg cfg) in
143
+ { fd with Linear. fun_body; fun_tailrec_entry_point_label }
142
144
end else
143
145
fd)
144
146
++ Profile. record ~accumulate: true " scheduling" Scheduling. fundecl
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ let create ~fun_name ~fun_tailrec_entry_point_label ~fun_dbg =
55
55
fun_dbg;
56
56
entry_label = 1 ;
57
57
blocks = Label.Tbl. create 31 ;
58
- fun_tailrec_entry_point_label = Some fun_tailrec_entry_point_label
58
+ fun_tailrec_entry_point_label
59
59
}
60
60
61
61
let mem_block t label = Label.Tbl. mem t.blocks label
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ type t = private
85
85
Otherwise, the [Prologue] falls through to this label. *)
86
86
}
87
87
88
- val create : fun_name :string -> fun_tailrec_entry_point_label :Label .t ->
88
+ val create : fun_name :string -> fun_tailrec_entry_point_label :Label .t option ->
89
89
fun_dbg :Debuginfo .t -> t
90
90
91
91
val fun_name : t -> string
Original file line number Diff line number Diff line change @@ -384,7 +384,7 @@ let print_assembly (blocks : Cfg.basic_block list) =
384
384
(* create a fake cfg just for printing these blocks *)
385
385
let layout = List. map (fun (b : Cfg.basic_block ) -> b.start) blocks in
386
386
let fun_name = " _fun_start_" in
387
- let fun_tailrec_entry_point_label = 0 in
387
+ let fun_tailrec_entry_point_label = Some 0 in
388
388
let cfg = Cfg. create ~fun_name ~fun_tailrec_entry_point_label
389
389
~fun_dbg: Debuginfo. none in
390
390
List. iter
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ type fundecl =
54
54
fun_fast : bool ;
55
55
fun_dbg : Debuginfo .t ;
56
56
fun_spacetime_shape : Mach .spacetime_shape option ;
57
- fun_tailrec_entry_point_label : label ;
57
+ fun_tailrec_entry_point_label : label option ;
58
58
fun_contains_calls : bool ;
59
59
fun_num_stack_slots : int array ;
60
60
fun_frame_required : bool ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ type fundecl =
55
55
fun_fast : bool ;
56
56
fun_dbg : Debuginfo .t ;
57
57
fun_spacetime_shape : Mach .spacetime_shape option ;
58
- fun_tailrec_entry_point_label : label ;
58
+ fun_tailrec_entry_point_label : label option ;
59
59
fun_contains_calls : bool ;
60
60
fun_num_stack_slots : int array ;
61
61
fun_frame_required : bool ;
Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ let fundecl f =
334
334
fun_fast = not (List. mem Cmm. Reduce_code_size f.Mach. fun_codegen_options);
335
335
fun_dbg = f.Mach. fun_dbg;
336
336
fun_spacetime_shape = f.Mach. fun_spacetime_shape;
337
- fun_tailrec_entry_point_label;
337
+ fun_tailrec_entry_point_label = Some fun_tailrec_entry_point_label ;
338
338
fun_contains_calls = contains_calls;
339
339
fun_num_stack_slots = f.Mach. fun_num_stack_slots;
340
340
fun_frame_required = Proc. frame_required f;
You can’t perform that action at this time.
0 commit comments