Skip to content

Commit 1dea1c1

Browse files
committed
Global dead code: small improvement
1 parent af981ba commit 1dea1c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/lib/global_deadcode.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module Domain : sig
4242

4343
val top : t
4444

45+
val live_block : t
46+
4547
val live_field : int -> t -> t
4648

4749
val join : t -> t -> t
@@ -74,6 +76,8 @@ end = struct
7476

7577
let depth_treshold = 4
7678

79+
let live_block = Live IntMap.empty
80+
7781
let live_field i l =
7882
(* We need to limit the depth of the liveness information,
7983
otherwise the information can get more and more precise without
@@ -385,11 +389,13 @@ let propagate defs scoped_live_vars ~state ~dep:y ~target:x ~action:usage_kind =
385389
vars;
386390
!live
387391
| Expr (Field (_, i, _)) -> Domain.live_field i l
392+
| Expr (Prim (IsInt, _)) -> Domain.live_block
388393
| _ -> Domain.top)
389394
(* If y is top and y is a field access, x depends only on that field *)
390395
| Top -> (
391396
match Var.Tbl.get defs y with
392397
| Expr (Field (_, i, _)) -> Domain.live_field i Domain.top
398+
| Expr (Prim (IsInt, _)) -> Domain.live_block
393399
| _ -> Domain.top))
394400
(* If x is used as an argument for parameter y, then contribution is liveness of y *)
395401
| Propagate { scope; src } ->

0 commit comments

Comments
 (0)