Skip to content

Commit 26ae9da

Browse files
committed
Propagate the change to the corresponding Linear type.
1 parent b46fca4 commit 26ae9da

File tree

8 files changed

+13
-9
lines changed

8 files changed

+13
-9
lines changed

backend/amd64/emit.mlp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ let emit_named_text_section func_name =
566566
(* Name of current function *)
567567
let function_name = ref ""
568568
(* Entry point for tail recursive calls *)
569-
let tailrec_entry_point = ref 0
569+
let tailrec_entry_point = ref None
570570

571571
(* Emit tracing probes *)
572572

@@ -722,7 +722,9 @@ let emit_instr fallthrough i =
722722
| Lop(Itailcall_imm { func; label_after; }) ->
723723
begin
724724
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)
726728
else begin
727729
output_epilogue begin fun () ->
728730
add_used_symbol func;

backend/asmgen.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ let compile_fundecl ~ppf_dump fd_cmm =
138138
if !use_ocamlcfg then begin
139139
let cfg = Ocamlcfg.Cfg_with_layout.of_linear fd ~preserve_orig_labels:true in
140140
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 }
142144
end else
143145
fd)
144146
++ Profile.record ~accumulate:true "scheduling" Scheduling.fundecl

backend/cfg/cfg.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let create ~fun_name ~fun_tailrec_entry_point_label ~fun_dbg =
5555
fun_dbg;
5656
entry_label = 1;
5757
blocks = Label.Tbl.create 31;
58-
fun_tailrec_entry_point_label = Some fun_tailrec_entry_point_label
58+
fun_tailrec_entry_point_label
5959
}
6060

6161
let mem_block t label = Label.Tbl.mem t.blocks label

backend/cfg/cfg.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type t = private
8585
Otherwise, the [Prologue] falls through to this label. *)
8686
}
8787

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 ->
8989
fun_dbg:Debuginfo.t -> t
9090

9191
val fun_name : t -> string

backend/cfg/cfg_to_linear.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ let print_assembly (blocks : Cfg.basic_block list) =
384384
(* create a fake cfg just for printing these blocks *)
385385
let layout = List.map (fun (b : Cfg.basic_block) -> b.start) blocks in
386386
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
388388
let cfg = Cfg.create ~fun_name ~fun_tailrec_entry_point_label
389389
~fun_dbg:Debuginfo.none in
390390
List.iter

backend/linear.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type fundecl =
5454
fun_fast: bool;
5555
fun_dbg : Debuginfo.t;
5656
fun_spacetime_shape : Mach.spacetime_shape option;
57-
fun_tailrec_entry_point_label : label;
57+
fun_tailrec_entry_point_label : label option;
5858
fun_contains_calls: bool;
5959
fun_num_stack_slots: int array;
6060
fun_frame_required: bool;

backend/linear.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type fundecl =
5555
fun_fast: bool;
5656
fun_dbg : Debuginfo.t;
5757
fun_spacetime_shape : Mach.spacetime_shape option;
58-
fun_tailrec_entry_point_label : label;
58+
fun_tailrec_entry_point_label : label option;
5959
fun_contains_calls: bool;
6060
fun_num_stack_slots: int array;
6161
fun_frame_required: bool;

backend/linearize.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ let fundecl f =
334334
fun_fast = not (List.mem Cmm.Reduce_code_size f.Mach.fun_codegen_options);
335335
fun_dbg = f.Mach.fun_dbg;
336336
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;
338338
fun_contains_calls = contains_calls;
339339
fun_num_stack_slots = f.Mach.fun_num_stack_slots;
340340
fun_frame_required = Proc.frame_required f;

0 commit comments

Comments
 (0)