Skip to content

Commit

Permalink
Fix global flow analysis (see #1556)
Browse files Browse the repository at this point in the history
It needs to take into account values flowing out of the toplevel function.
  • Loading branch information
vouillon committed Sep 23, 2024
1 parent dbcf6a2 commit 241a5c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 0 additions & 9 deletions compiler/lib/global_deadcode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)
Expand Down
11 changes: 10 additions & 1 deletion compiler/lib/global_flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) ->
Expand Down

0 comments on commit 241a5c6

Please sign in to comment.