Skip to content

Commit 28b9357

Browse files
committed
Kill residual dead code in Trans.iter_tag_parts. Shaves a couple kb off rustc.
1 parent 71d49a2 commit 28b9357

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/boot/me/trans.ml

+11-1
Original file line numberDiff line numberDiff line change
@@ -2719,19 +2719,29 @@ let trans_visitor
27192719
if Array.length ttup <> 0
27202720
then
27212721
begin
2722+
let pc0 = (emitter()).Il.emit_pc in
27222723
(iflog (fun _ ->
27232724
annotate (Printf.sprintf "tag case #%i" i)));
27242725
let jmps =
27252726
trans_compare_simple Il.JNE
27262727
(Il.Cell tmp) (imm (Int64.of_int i))
27272728
in
27282729
let ttup = get_nth_tag_tup cx ttag i in
2730+
let pc1 = (emitter()).Il.emit_pc in
27292731
iter_tup_parts
27302732
(get_element_ptr_dyn ty_params)
27312733
(get_variant_ptr dst_union i)
27322734
(get_variant_ptr src_union i)
27332735
ttup f;
2734-
List.iter patch jmps
2736+
2737+
(* Hack: if this variant is all dead code, blank it out. *)
2738+
if pc1 = (emitter()).Il.emit_pc
2739+
then
2740+
begin
2741+
for j = pc0 to (pc1-1)
2742+
do (emitter()).Il.emit_quads.(j) <- Il.deadq done
2743+
end;
2744+
List.iter patch jmps;
27352745
end
27362746
done;
27372747

0 commit comments

Comments
 (0)