File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -483,16 +483,17 @@ let zero prog pure_funs sentinal live_table =
483483 (* Zero out return values in last instruction, otherwise do nothing. *)
484484 match block.branch with
485485 | Return x ->
486- let tc =
487- (* We don't want to break tailcalls. *)
486+ let live_tc =
487+ (* Don't break tailcalls, it's needed for generate_closure
488+ and effects passes. If the (tail)call is dead, it will
489+ be eliminated later by the deadcode pass, don't make it live again by
490+ returning its result. *)
488491 match List. last body with
489- | Some (Let (x' , (Apply _ as e ))) when Code.Var. equal x' x ->
490- if (not (is_live x')) && Pure_fun. pure_expr pure_funs e
491- then false (* we don't want to stop deadcode *)
492- else true
492+ | Some (Let (x' , (Apply _ as e ))) ->
493+ Code.Var. equal x x' && (is_live x' || not (Pure_fun. pure_expr pure_funs e))
493494 | Some _ | None -> false
494495 in
495- if tc then Return x else Return (zero_var x)
496+ if live_tc then Return x else Return (zero_var x)
496497 | Raise (_, _)
497498 | Stop | Branch _
498499 | Cond (_, _, _)
You can’t perform that action at this time.
0 commit comments