The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Do not emit references to dead labels (spacetime) (#9097)

authored by

Greta Yorsh and committed by
Mark Shinwell
6daaf629 05f15cf2

+28 -6
+3
Changes
··· 84 84 - #9064: Relax the level handling when unifying row fields 85 85 (Leo White, review by Jacques Garrigue) 86 86 87 + - #9097: Do not emit references to dead labels introduced by #2321 (spacetime). 88 + (Greta Yorsh, review by Mark Shinwell) 89 + 87 90 OCaml 4.10.0 88 91 ------------ 89 92
+22 -6
asmcomp/amd64/emit.mlp
··· 28 28 open X86_proc 29 29 open X86_dsl 30 30 module String = Misc.Stdlib.String 31 + module Int = Numbers.Int 31 32 32 33 (* [Branch_relaxation] is not used in this file, but is required by 33 34 emit.mlp files for certain other targets; the reference here ensures ··· 171 172 172 173 let label s = sym (emit_label s) 173 174 174 - let def_label s = D.label (emit_label s) 175 + (* For Spacetime, keep track of code labels that have been emitted. *) 176 + let used_labels = ref Int.Set.empty 177 + 178 + let mark_used lbl = 179 + if Config.spacetime && not (Int.Set.mem lbl !used_labels) then begin 180 + used_labels := Int.Set.add lbl !used_labels 181 + end 182 + 183 + let def_label ?typ s = 184 + mark_used s; 185 + D.label ?typ (emit_label s) 175 186 176 187 let emit_Llabel fallthrough lbl = 177 188 if not fallthrough && !fastcode_flag then D.align 4; ··· 1002 1013 reset_imp_table(); 1003 1014 float_constants := []; 1004 1015 all_functions := []; 1016 + used_labels := Int.Set.empty; 1005 1017 if system = S_win64 then begin 1006 1018 D.extrn "caml_call_gc" NEAR; 1007 1019 D.extrn "caml_c_call" NEAR; ··· 1049 1061 begin match fundecl.fun_spacetime_shape with 1050 1062 | None -> () 1051 1063 | Some shape -> 1052 - let funsym = emit_symbol fundecl.fun_name in 1053 - D.comment ("Shape for " ^ funsym ^ ":"); 1054 - D.qword (ConstLabel funsym); 1055 - List.iter (fun (part_of_shape, label) -> 1064 + (* Instrumentation that refers to dead code may have been eliminated. *) 1065 + match List.filter (fun (_, l) -> Int.Set.mem l !used_labels) shape with 1066 + | [] -> () 1067 + | shape -> 1068 + let funsym = emit_symbol fundecl.fun_name in 1069 + D.comment ("Shape for " ^ funsym ^ ":"); 1070 + D.qword (ConstLabel funsym); 1071 + List.iter (fun (part_of_shape, label) -> 1056 1072 let tag = 1057 1073 match part_of_shape with 1058 1074 | Direct_call_point _ -> 1 ··· 1067 1083 | Indirect_call_point -> () 1068 1084 | Allocation_point -> () 1069 1085 end) 1070 - shape; 1086 + shape; 1071 1087 D.qword (Const 0L) 1072 1088 end) 1073 1089 !all_functions;
+2
utils/numbers.ml
··· 31 31 32 32 let rec zero_to_n n = 33 33 if n < 0 then Set.empty else Set.add n (zero_to_n (n-1)) 34 + 35 + let to_string n = Int.to_string n 34 36 end 35 37 36 38 module Int8 = struct
+1
utils/numbers.mli
··· 26 26 27 27 (** [zero_to_n n] is the set of numbers \{0, ..., n\} (inclusive). *) 28 28 val zero_to_n : int -> Set.t 29 + val to_string : int -> string 29 30 end 30 31 31 32 module Int8 : sig