diff --git a/compiler/lib/global_deadcode.ml b/compiler/lib/global_deadcode.ml index c3670b350e..b56c0d5cdd 100644 --- a/compiler/lib/global_deadcode.ml +++ b/compiler/lib/global_deadcode.ml @@ -253,15 +253,6 @@ let liveness prog pure_funs (global_info : Global_flow.info) = | Stop | Branch _ | Poptrap _ | Pushtrap _ -> () in Addr.Map.iter (fun _ block -> live_block block) prog.blocks; - Code.traverse - { Code.fold = Code.fold_children } - (fun pc () -> - match Addr.Map.find pc prog.blocks with - | { branch = Return x, _; _ } -> add_top x - | _ -> ()) - prog.start - prog.blocks - (); live_vars (* Returns the set of variables given a table of variables. *) diff --git a/compiler/lib/global_flow.ml b/compiler/lib/global_flow.ml index 8cc7368aca..66ce9fe395 100644 --- a/compiler/lib/global_flow.ml +++ b/compiler/lib/global_flow.ml @@ -233,7 +233,16 @@ let expr_deps blocks st x e = cont_deps blocks st cont | Field (y, _, _) -> add_dep st x y -let program_deps st { blocks; _ } = +let program_deps st { start; blocks; _ } = + Code.traverse + { Code.fold = Code.fold_children } + (fun pc () -> + match Addr.Map.find pc blocks with + | { branch = Return x, _; _ } -> do_escape st Escape x + | _ -> ()) + start + blocks + (); Addr.Map.iter (fun _ block -> List.iter block.body ~f:(fun (i, _) ->