Skip to content

Fix global flow analysis #1680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Toplevel: fix missing primitives with separate compilation
* Compiler: fix link of packed modules with separate compilation
* Compiler: Fixed the static evaluation of some equalities (#1659)
* Compiler: fix global analysis bug (subsumes #1556)

# 5.8.2 (2024-05-26) - Luc

Expand Down
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